这是我的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