我有以下代码:
tabControl = Notebook(root)
tab0 = Frame(tabControl)
tab0.pack(fill="both")
tabControl.add(tab0, text="Wardrobe")
tab1 = Frame(tabControl)
tab1.pack(fill='both')
tabControl.add(tab1, text='Weapons', state='normal')
tab2 = Frame(tabControl)
tab2.pack(fill='both')
tabControl.add(tab2, text='Ammo', state='normal')
tabControl.pack(expand=1, fill="both")
# determine canvas
w = 1000
h = 1500
canvas = Canvas(tab0, width=w, height=h, relief='ridge', scrollregion=(0, 0, w, h), highlightthickness=0)
sbar = Scrollbar(tab0, orient=VERTICAL)
sbar.pack(side=RIGHT, fill=Y)
sbar.config(command=canvas.yview)
canvas.config(width=w, height=h)
canvas.config(yscrollcommand=sbar.set)
canvas.pack(side=LEFT, expand=True, fill=BOTH)
# WARDROBE
# photos
planep = PhotoImage(file='images/plane pic.png')
plane = Label(canvas, image=planep)
plane.pack()
plane.place(relx=0.3, y=100, anchor='center')
我设法使滚动条移动,但是当我“滚动”时,除了滚动条移动之外,屏幕上什么都没有发生(图像标签始终保持在同一位置)。我还添加了一个向其添加图像标签的示例,因为我认为问题在于确定放置平面图片的y=100
。
有谁知道我该怎么办?
预先感谢。