這是我的Tkinter代碼。我打算顯示水平和垂直滾動條。Tkinter程序:不顯示底部滾動條
from Tkinter import *
root = Tk()
scrollbar = Scrollbar(root)
scrollbar.pack(side = RIGHT,fill = Y)
scrollbar_x = Scrollbar(root)
scrollbar_x.pack(side = BOTTOM,fill = X)
mylist = Listbox(root,xscrollcommand = scrollbar_x.set,yscrollcommand = scrollbar.set)
"""
To connect a scrollbar to another widget w, set w's xscrollcommand or yscrollcommand to the scrollbar's set() method. The arguments have the same meaning as the values returned by the get() method.
"""
for line in range(100):
mylist.insert(END,("this is line number"+str(line))*100)
mylist.pack(side = LEFT,fill=BOTH)
scrollbar.config(command = mylist.yview)
scrollbar_x.config(command = mylist.xview)
print root.pack_slaves()
mainloop()
而且這與我在我的電腦中預測的不匹配,即Mac Sierra。 此外,scrollbar.config(command = mylist.yview)
是什麼意思?
config()
有關該功能的更多細節會有所幫助〜感謝
有趣的 - 首先你說 - 這是你的代碼;那麼你會問你的代碼中的命令是什麼意思。嘗試去通過tkinter教程 - 你會明白這個命令的含義 – Drako