0
我有一些問題tkinter/ttk
。Python 3. TTK。如何改變特定細胞的價值?
所以,我知道如何獲取Treeview.focus,但如何更改此表中特定單元格的值?有什麼建議麼?
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
tview = ttk.Treeview(root)
tview["columns"] = ("SLOT_1","SLOT_2")
tview.column("SLOT_1", width=100)
tview.column("SLOT_2", width=100)
tview.heading("#0",text="Column 0",anchor="w")
tview.heading("SLOT_1", text="Column 1")
tview.heading("SLOT_2", text="Column 2")
def add_item():
tview.insert("","end",values=("","bar"))
def edit_item():
focused = tview.focus()
print(tview.item(focused))
tview.pack()
add_item = tk.Button(root,text="Add item",command=add_item)
add_item.pack(expand=True,fill='both')
edit_item = tk.Button(root,text="Edit item",command=edit_item)
edit_item.pack(expand=True,fill='both')
root.mainloop()
我使用Python 3.6
與tkinter/ttk
。