1

I'm using python 2.7 and Tkinter to design a basic tool to fill a table with information. I want to be able to edit the Display name category by just clicking on it and also have a button in the delete column to delete it from the treeview.. My code is below and a mockup image of what I'm generally trying to make can be found here Link for mockup. Here is the code I have so far:

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()

I'm new to Tkinter and TkDocs is kind of confusing. Thanks

Karsten Andersen
  • 115
  • 5
  • 16
  • I constantly refer to http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html. However, it is not flawless (has a few errors), and I sometimes refer to http://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm though is it harder to read. Note that Treeview is the last widget discussed in the tkdocs tutorial http://www.tkdocs.com/tutorial/index.html. I may be the hardest to learn. – Terry Jan Reedy Aug 02 '16 at 18:43

1 Answers1

0

Same answer as for previous question about inserting widgets into Treeview. You can only insert strings.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52