我已經構建了一個Listbox并將其系結到一個水平Scrollbar,但是當我運行它時,它奇怪地顯示在螢屏上。
有用的代碼片段:
listframel = Frame(root)
listframel.grid(row=0, column=0, sticky=NSEW, rowspan=5)
listframel.configure(bg="white")
listframel.grid_rowconfigure((0,1,2,3,4), weight=1)
listframel.grid_columnconfigure((0,), weight=1)
scrollbar2 = Scrollbar(listframel)
scrollbar2.pack(side=BOTTOM, fill=X)
listbox = Listbox(listframel, xscrollcommand=scrollbar2.set, yscrollcommand=scrollbar.set, font=conforta, borderwidth=0)
listbox.pack(fill=BOTH, expand=1)
scrollbar2.config(command=listbox.xview)
這是一個有用的螢屏截圖:

滾動條按預期作業,但無法正確顯示。是我的作業系統問題還是我的代碼問題?
uj5u.com熱心網友回復:
orient='horizontal'您需要在創建小部件時通過設定將水平滾動條配置為水平滾動條:
scrollbar2 = Scrollbar(listframel, orient='horizontal')
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/446474.html
上一篇:實時Tkinter標簽
