Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- import textwrap
- def wrap(string, lenght=8):
- return '\n'.join(textwrap.wrap(string, lenght))
- myApp = Tk()
- NewTree = ttk.Treeview(myApp, height=5)
- NewTree['show'] = 'headings'
- s = ttk.Style()
- s.configure('Treeview', rowheight=20)
- NewTree["columns"] = ("1", "2")
- NewTree.column("1", width=60)
- NewTree.column("2", width=60)
- NewTree.heading("1", text="col a")
- NewTree.heading("2", text="col b")
- item = NewTree.insert("", "end", values=(wrap("i want to wrap this text"),
- wrap("and this text")))
- NewTree.grid(row=0, column=0)
- myApp.mainloop()
- #---------------------------------------------------------------
- from tkinter import *
- from tkinter import ttk
- import textwrap
- def wrap(string, lenght=20):
- return '\n'.join(textwrap.wrap(string, lenght))
- ws = Tk()
- ws.title("PythonGuides")
- tv = ttk.Treeview(ws, columns=(1, 2, 3), show='headings', height=8)
- tv.pack()
- tv.heading(1, text="name")
- tv.heading(2, text="eid")
- tv.heading(3, text="Salary")
- def update_item():
- selected = tv.focus()
- temp = tv.item(selected, 'values')
- sal_up = float(temp[2]) + float(temp[2]) * 0.05
- tv.item(selected, values=(temp[0], temp[1], sal_up))
- tv.insert(parent='', index=0, iid=0, values=(wrap("vineet hkjhk ljljoi vgvgvy daaaa Aleksandyr georgiev Georgiew"), "e11", 1000000.00))
- tv.insert(parent='', index=1, iid=1, values=("anil", "e12", 120000.00))
- tv.insert(parent='', index=2, iid=2, values=("ankit", "e13", 41000.00))
- tv.insert(parent='', index=3, iid=3, values=("Shanti", "e14", 22000.00))
- Button(ws, text='Increment Salary', command=update_item).pack()
- style = ttk.Style()
- style.theme_use("default")
- style.map("Treeview")
- ws.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement