我写了下面的代码:
def fee_foo():
fee_screen = tk.Tk()
fee_screen.title("Fee Information")
fee_screen.geometry("500x500")
# Execute the SELECT statement and retrieve the results
# Execute the SELECT statement and retrieve the results
query = "SELECT roll_no, paid, due_date, amount FROM fee"
cursor.execute(query)
results = cursor.fetchall()
# Create the Treeview widget
treeview = ttk.Treeview(fee_screen)
treeview.pack(fill=tk.BOTH, expand=True)
# Configure the columns of the Treeview widget
treeview["columns"] = ("roll_no","paid", "due_date", "amount")
treeview.column("roll_no",width=100)
treeview.column("paid", width=100)
treeview.column("due_date", width=100)
treeview.column("amount", width=100)
# Set the column headers of the Treeview widget
treeview.heading("roll_no",text="Roll No")
treeview.heading("paid", text="Paid")
treeview.heading("due_date", text="Due Date")
treeview.heading("amount", text="Amount")
# Insert the rows into the Treeview widget
for result in results:
treeview.insert("", tk.END, text=result[0], values=result[1:])
但我得到的结果是这样的:enter image description here您能告诉我代码有什么问题吗?
我尝试更改列和标题变量的值,并在treeview.insert行中重新索引元组。
1条答案
按热度按时间lb3vh1jj1#
如果我们这样修改列的排列,我找到了答案:
它显示正确的列排列