Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import ttk
- import tkinter as tk
- blow = [("january", "2013"),("february", "2014"),("march", "2015"),("april", "2016"),("may", "2017")]
- def append_select():
- cur_id = tree.focus()
- for child in tree2.selection():
- #for child in tree2.get_children():
- if cur_id in child:
- print("item exist")
- elif cur_id:
- tree2.insert("", tk.END, values=tree.item(cur_id)['values'])
- root = tk.Tk()
- root.geometry("500x500")
- tree = ttk.Treeview(columns=("columns1", "columns"), show="headings", selectmode="browse")
- tree.heading("#1", text="Month")
- tree.heading("#2", text="Year")
- for n in blow:
- tree.insert("", tk.END, values=(n))
- tree.pack()
- b1 = tk.Button(text="append", command=append_select)
- b1.pack()
- tree2 = ttk.Treeview(columns=("Month", "Year"), show="headings")
- tree2.heading("#1", text="month")
- tree2.heading("#2", text="year")
- tree2.pack()
- root.mainloop()
Add Comment
Please, Sign In to add comment