|

楼主 |
发表于 2021-5-26 14:40:07
|
显示全部楼层
我的代码:
- #!/usr/bin/python3
- import tkinter as tk
- from tkinter import ttk
- root = tk.Tk()
- root.title(string = 'The example of ttk notebook')
- root.geometry('400x300+200+200')
- tabControl = ttk.Notebook(root)
- tab1 = tk.Frame(tabControl, bg = 'blue', width = '400')
- tabControl.add(tab1, text = 'information')
- tab2 = tk.Frame(tabControl, bg = 'green')
- tabControl.add(tab2, text = 'coding')
- tab3 = tk.Frame(tabControl, bg = 'yellow')
- tabControl.add(tab3, text = 'python')
- ac=('tree_view','status')
- tab4 = tk.Frame(tabControl)
- tabControl.add(tab4, text = 'TCL')
- tree = ttk.Treeview(tab1,columns=ac)
- tree.column('#0',width = 300)
- tree.column('#1',width = 100)
- tree.heading('#0',text = 'tree head', anchor = 'w')
- tree.heading('#1',text = 'status', anchor = 'w')
- tree.tag_configure('Error',background='red')
- tree.tag_configure('Warning', background='yellow',foreground='white')
- myid = tree.insert("", 0, "mla_t", text="mal_t", open=True )
- myidx1 = tree.insert(myid, 1, "mla_t_test", text="mla_t_test", values=("11"))
- myidx2 = tree.insert(myid, 1, "mla_t_work", text="mla_t_work", values=("21"))
- tree.pack(expand = 1, fill = 'both')
- tree.item(myidx1, tags = ('Warning','Error'))
- tabControl.pack(expand = 1, fill = 'both')
- root.mainloop()
复制代码 |
|