[Tutor] Displaying image in scrolled canvas
kromag@nsacom.net
kromag@nsacom.net
Mon, 30 Apr 2001 10:40:38 -0700 (PDT)
I am attempting to place a large .gif file into a scrolled canvas. I am
working from the examples in programming python (in case the code looked
slightly familiar :-)
To wit:
from Tkinter import *
class ScrolledCanvas(Frame):
def __init__(self, parent=None, color='white'):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
photo=PhotoImage(file='\windows\desktop\wacky3.gif')
canv = Canvas(self, bg=color, relief=SUNKEN)
canv.config(width=1010, height=745)
canv.config(scrollregion=(0,0,300, 1000))
canv.create_image(10,10, image=photo, anchor=NW)
sbar = Scrollbar(self)
sbar.config(command=canv.yview)
canv.config(yscrollcommand=sbar.set)
sbar.pack(side=RIGHT, fill=Y)
canv.pack(side=LEFT, expand=YES, fill=BOTH)
if __name__ == '__main__': ScrolledCanvas().mainloop()
results in the properly-sized frame and scrollbar, but for some reason the
image does not pop to life. What am I missing here?
d