使用 Tkinter for 2.7.5 我想在下面的代码中添加一个滚动条,以便可以查看所有按钮。
谢谢你。
代码:
import Tkinter, tkMessageBox root = Tkinter.Tk() def centerRoot(w = 240, h = 498): ws = root.winfo_screenwidth() hs = root.winfo_screenheight() x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, x, y)) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=0,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=0,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=1,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=1,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=2,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=2,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=3,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=3,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=4,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=4,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=5,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=5,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=6,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=6,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=7,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=7,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=8,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=8,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=9,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=9,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=10,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=10,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=11,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=11,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=12,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=12,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=13,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=13,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=14,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=14,column=1) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=15,column=0) Tkinter.Button(root, height=2, width=10, text='Text', borderwidth=10).grid(row=15,column=1) centerRoot() root.title('Title Here') root.mainloop()