def _setup_widgets(self):
msg = ttk.Label(wraplength="4i", justify="left", anchor="n",
padding=(10, 2, 10, 6),
text=("Ttk is the new Tk themed widget set. One of the widgets it "
"includes is a tree widget, which can be configured to "
"display multiple columns of informational data without "
"displaying the tree itself. This is a simple way to build "
"a listbox that has multiple columns. Clicking on the "
"heading for a column will sort the data by that column. "
"You can also change the width of the columns by dragging "
"the boundary between them."))
msg.pack(fill='x')
container = ttk.Frame()
container.pack(fill='both', expand=True)
# XXX Sounds like a good support class would be one for constructing
# a treeview with scrollbars.
self.tree = ttk.Treeview(columns=tree_columns, show="headings")
vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
self.tree.grid(column=0, row=0, sticky='nsew', in_=container)
vsb.grid(column=1, row=0, sticky='ns', in_=container)
hsb.grid(column=0, row=1, sticky='ew', in_=container)
container.grid_columnconfigure(0, weight=1)
container.grid_rowconfigure(0, weight=1)
treeview_multicolumn.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录