2016-08-02 211 views
0

我正在使用python 2.7和Tkinter設計一個基本工具來填充信息表。我希望能夠通過點擊它來編輯顯示名稱類別,並且在刪除列中有一個按鈕可以從樹形視圖中刪除它。我的代碼如下,並且是我通常試圖製作的模型圖像可以在這裏找到Link for mockup。這裏是我到目前爲止的代碼:對Tkinter的將按鈕和文本框添加到Tkinter Treeview中的行

from Tkinter import * 
import ttk 

root = Tk() 
root.wm_title("Manage") 

frame = ttk.Frame(root) 
frame.pack() 

tree=ttk.Treeview(frame) 

style = ttk.Style() 
style.configure(".", font = ("Helvetica", 14)) 
style.configure("Treeview.Heading", font = ("Helvetica", 16)) 

tree["columns"] = ("one", "two", "three", "four") 
tree.column("one", width=170) 
tree.column("two", width=255) 
tree.column("three", width=510) 
tree.column("four", width=85) 

tree.heading('#0', text = "Type") 
tree.heading("one", text = "Category") 
tree.heading("two", text = "Display Name") 
tree.heading("three", text = "GUID") 
tree.heading("four", text = "Delete") 

tree.insert("" , 0, text = "Line 1", values = ("1A","1b"), tag = "orow") 

id2 = tree.insert("", 1, "dir2", text = "Dir 2", tag = "erow") 
tree.insert(id2, "end", "dir 2", text = "sub dir 2", values = ("2A","2B")) 

tree.tag_configure('orow', background = '#EEEEEE') 
tree.tag_configure('erow', background = '#CACBCB') 

tree.pack() 
root.mainloop() 

我是新和TkDocs是一種混亂。謝謝

+0

我經常引用http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html。然而,它並不完美(有一些錯誤),我有時會參考http://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm,雖然它很難閱讀。請注意,Treeview是tkdocs教程http://www.tkdocs.com/tutorial/index.html中討論的最後一個小部件。我可能是最難學習的。 –

回答

0

與爲previous question相同的問題關於插入小部件到Treeview。您只能插入字符串。

相關問題