以下程序:
import sys
import os
os.chdir('/Users/eduardomartinez/Desktop/artista')
sys.path.append('/Users/eduardomartinez/Desktop/Imaging-1.1.6')
from Tkinter import *
from PIL import Image, ImageTk
root = Tk()
im = Image.open('samples.png')
imtk = ImageTk.PhotoImage(im)
imageframe = Frame(root)
canvas = Canvas(imageframe)
canvas.create_image(0, 0, image=imtk, anchor="nw")
print canvas.bbox('all')
canvas.config(scrollregion=canvas.bbox('all'))
scrollx = Scrollbar(imageframe, orient=HORIZONTAL)
scrolly = Scrollbar(imageframe, orient=VERTICAL)
scrollx.config(command=canvas.xview)
scrolly.config(command=canvas.yview)
canvas.grid(column=0, row=0, sticky=W+E+N+S)
w = imtk.width()
h = imtk.height()
cw = canvas.winfo_width()
ch = canvas.winfo_height()
if w > cw:
scrollx.grid(column=0, row=1, sticky=W+E)
if h > ch:
scrolly.grid(column=1, row=0, sticky=N+S)
imageframe.columnconfigure(index=0, weight=1)
imageframe.rowconfigure(index=0, weight=1)
imageframe.pack()
root.mainloop()
抛出如下错误:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1570, in yview
res = self.tk.call(self._w, 'yview', *args)
TclError: unknown option "0": must be moveto or scroll
每当我尝试垂直滚动时(以及水平滚动时的类似错误)。我做错什么了?你知道吗
(是的,警察,我的帖子主要是代码。我不认为这一段,旨在平衡我的职位,以符合您的指导方针,改善任何东西)
目前没有回答
相关问题 更多 >
编程相关推荐