我試圖在桌子上放置滾動條,但無論我如何嘗試,它們都沒有出現。這是我到目前為止所擁有的:
'''
# Table Frame
tree_frame = Frame(root, bg="#ecf0f1")
tree_frame.place(x=0, y=380, width=1980, height=520)
style = ttk.Style()
style.configure("mystyle.Treeview", font=('Calibri', 18),
rowheight=50) # Modify the font of the body
style.configure("mystyle.Treeview.Heading", font=('Calibri', 18)) # Modify the font of the headings
tv = ttk.Treeview(tree_frame, columns=(1, 2, 3, 4, 5, 6), style="mystyle.Treeview")
#scrollbar
tree_scroll = Scrollbar(tree_frame)
tree_scroll.pack(side=RIGHT, fill=Y)
tree_scroll = Scrollbar(tree_frame,orient='horizontal')
tree_scroll.pack(side= BOTTOM,fill=X)
my_tree = ttk.Treeview(tree_frame,yscrollcommand=tree_scroll.set, xscrollcommand =tree_scroll.set)
tv.column("# 1",anchor=W, stretch=NO, width=100)
tv.heading("# 1", text="ID")
tv.column("# 2", anchor=W, stretch=NO)
tv.heading("# 2", text="Catagory")
tv.column("# 3", anchor=W, stretch=NO, width=150)
tv.heading("# 3", text="Brand")
tv.column("# 4", anchor=W, stretch=NO, width=255)
tv.heading("# 4", text="Model")
tv.column("# 5", anchor=W, stretch=NO, width=375)
tv.heading("# 5", text="Serial#")
tv.column("# 6", anchor=W, stretch=NO)
tv.heading("# 6", text="Notes")
tv['show'] = 'headings'
tv.bind("<ButtonRelease-1>", getData)
tv.pack(fill=X)
''' 誰有想法?這是我的輸出:

uj5u.com熱心網友回復:
滾動條在那里。問題是,你使用place上tree_frame防止調整大小以適應小部件的視窗。如果您手動使視窗足夠大,滾動條將變得可見。
如果您使用pack或grid適當的選項,視窗將自動調整大小以使所有小部件可見。
tree_frame.pack(side="top", fill="both", expand=True)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/350410.html
