1
下面是我正在做的一個示例。我在滑動畫布上放置了500個按鈕,而且我只能滾動到按鈕109.我在做什麼錯了?我試着調整窗口小部件的寬度,以及scrollregion。我確信我忽略了一些簡單的東西。Tkinter,我無法讓我的滑塊顯示所有按鈕
import Tkinter
from Tkinter import *
import os, signal
window1 = Tkinter.Tk()
window1.attributes('-fullscreen', True)
window1.bind("<Escape>", lambda e: e.widget.quit())
window2 = Tkinter.Label(window1)
window2.configure(bg = "blue")
window2.place(x=0, y=0, relwidth=1, relheight=1)
frame=Frame(window2, height=160)
frame.pack(anchor=Tkinter.SW,side=Tkinter.BOTTOM)
canvas=Canvas(frame,bg='black', width=5500, height=160, scrollregion=(0,0,5500,0))
hbar=Scrollbar(frame,orient=HORIZONTAL, bg='black', troughcolor='black')
hbar.pack(side=BOTTOM,fill=X)
hbar.config(command=canvas.xview)
canvas.config(xscrollcommand=hbar.set, xscrollincrement=4.5)
canvas.pack(side=LEFT,expand=True,fill=BOTH)
frm = Frame(canvas)
canvas.create_window(0, 0, window=frm, anchor='nw')
def quit():
window1.quit()
count = 0
while (count < 500):
X = Tkinter.Button(frm, text=str(count), height=6, width=5, padx=0, pady=0, highlightcolor="blue", highlightthickness=3, command=quit)
X.pack(side = "left")
count = count + 1
window1.mainloop()