SHARE
TWEET

Untitled

a guest Jun 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. from tkinter import ttk
  3.  
  4. root = Tk()
  5.  
  6. tree = ttk.Treeview(root, columns=("order", "name", "price"))
  7.  
  8. def itemEvent(event):
  9.     for item in tree.selection():
  10.         item_text = tree.item(item, "values")
  11.         print(item_text[0:2])
  12.  
  13.  
  14. tree["show"] = "headings"
  15. tree.heading("order", text="Order")
  16. tree.column("order",minwidth=0,width=50)
  17. tree.heading("name", text="Name")
  18. tree.heading("price", text="Price")
  19.  
  20. tree.insert("", "end", values=(1,"SSD", "49€"))
  21. tree.insert("", "end", values=(2,"Pendrive", "9€"))
  22. tree.insert("", "end", values=(3,"USB", "4€","Edit"))
  23. tree.insert("", "end", values=(4,"Hard Drive", "29€"))
  24.  
  25. tree.bind("<Double-1>", itemEvent)
  26. tree.pack()
  27.  
  28. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top