我正在尝试将滚动条添加到我的树状视图。。。但是我不知道如何用我现有的代码来实现它。此外,我在开始时得到了一个额外的专栏。有人能告诉我为什么我会得到这个吗
Tree View Code
tree = ttk.Treeview(formcontainer, columns=("name", "fathersname",
"mothersname","rollno","studentid","contact","email","dob"))
tree.heading('name', text="Student Name", anchor=W)
tree.column("name",minwidth=0,width=100, stretch=NO)
tree.heading('fathersname', text="Father's Name",anchor=CENTER)
tree.column("fathersname",minwidth=0,width=100, stretch=NO)
tree.heading('mothersname', text="Mother's Name", anchor=W)
tree.column("mothersname",minwidth=0,width=100, stretch=NO)
tree.heading('rollno', text="Roll Number", anchor=W)
tree.column("rollno",minwidth=0,width=100, stretch=NO)
tree.heading('studentid', text="Student ID", anchor=W)
tree.column("studentid",minwidth=0,width=100, stretch=NO)
tree.heading('contact', text="Contact", anchor=W)
tree.column("contact",minwidth=0,width=100, stretch=NO)
tree.heading('email', text="Email", anchor=W)
tree.column("email",minwidth=0,width=100, stretch=NO)
tree.heading('dob', text="Date of Birth", anchor=W)
tree.column("dob",minwidth=0,width=100, stretch=NO)
tree.grid(row=0,column=0)
Update Function
def updateview():
conn = sqlite3.connect('example.db')
c = conn.cursor()
t = ('Rahul',)
records = c.execute("SELECT * FROM students")
fatcheddata = tree.get_children()
for elements in fatcheddata:
tree.delete(elements)
print (fatcheddata)
for row in records:
# print(row)
tree.insert("", tk.END, values=row)
conn.commit()
conn.close()
第一列是treeview的“树”部分。您可以通过使用
show
方法来隐藏它,该方法接受一个包含一个或两个单词“tree”和“headers”的字符串。如果不包含“tree”,则该列将被隐藏相关问题 更多 >
编程相关推荐