Guest User

Untitled

a guest
Mar 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. from tkinter import ttk
  2. import tkinter as tk
  3.  
  4.  
  5. blow = [("january", "2013"),("february", "2014"),("march", "2015"),("april", "2016"),("may", "2017")]
  6.  
  7. def append_select():
  8. cur_id = tree.focus()
  9.  
  10. for child in tree2.selection():
  11. #for child in tree2.get_children():
  12. if cur_id in child:
  13. print("item exist")
  14. elif cur_id:
  15. tree2.insert("", tk.END, values=tree.item(cur_id)['values'])
  16.  
  17.  
  18. root = tk.Tk()
  19. root.geometry("500x500")
  20.  
  21. tree = ttk.Treeview(columns=("columns1", "columns"), show="headings", selectmode="browse")
  22. tree.heading("#1", text="Month")
  23. tree.heading("#2", text="Year")
  24. for n in blow:
  25. tree.insert("", tk.END, values=(n))
  26. tree.pack()
  27.  
  28. b1 = tk.Button(text="append", command=append_select)
  29. b1.pack()
  30.  
  31. tree2 = ttk.Treeview(columns=("Month", "Year"), show="headings")
  32. tree2.heading("#1", text="month")
  33. tree2.heading("#2", text="year")
  34. tree2.pack()
  35.  
  36. root.mainloop()
Add Comment
Please, Sign In to add comment