如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import tkinter from tkinter import ttk #导入内部包 win=tkinter.Tk() tree=ttk.Treeview(win) #表格 tree[ "columns" ]=( "姓名" , "年龄" , "身高" ) tree.column( "姓名" ,width=100) #表示列,不显示 tree.column( "年龄" ,width=100) tree.column( "身高" ,width=100) tree.heading( "姓名" ,text= "姓名-name" ) #显示表头 tree.heading( "年龄" ,text= "年龄-age" ) tree.heading( "身高" ,text= "身高-tall" ) tree.insert( "" ,0,text= "line1" ,values=( "1" , "2" , "3" )) #插入数据, tree.insert( "" ,1,text= "line1" ,values=( "1" , "2" , "3" )) tree.insert( "" ,2,text= "line1" ,values=( "1" , "2" , "3" )) tree.insert( "" ,3,text= "line1" ,values=( "1" , "2" , "3" )) tree.pack() win.mainloop() |
以上这篇详谈Python 窗体(tkinter)表格数据(Treeview)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/houyanhua1/article/details/78174470