在画布中的水平滚动条在tkinter

时间:2014-10-25 20:15:23

标签: python python-2.7 canvas tkinter scrollbar

我试图在tkinter的画布中添加水平滚动条。这就是我所做的(从本教程中删除 - http://www.tutorialspoint.com/python/tk_scrollbar.htm):

from Tkinter import *

root = Tk()
scrollbar = Scrollbar(root) 
scrollbar.pack( side = RIGHT, fill=Y )

mylist = Canvas(root, yscrollcommand = scrollbar.set, scrollregion= (0, 0, 5000, 5000))
for line in range(100):
   Label(mylist, text= "This is line number %s" %str(line)).pack()

mylist.pack( side = LEFT, fill = BOTH )
scrollbar.config( command = mylist.yview )



mainloop()

这是我得到的:

screenshot

不幸的是,移动滚动条什么都不做。有人可以帮忙解决这个问题吗?

0 个答案:

没有答案