[Tutor] Tutor Digest, Vol 20, Issue 37

Joseph Quigley cpu.crazy at gmail.com
Tue Oct 11 01:07:47 CEST 2005


Michael Wrote:

>Hi Joe,
>
>the image won't refresh until you explicitely tell Tk to do so, so you would have to do some more
>in newPic(); btw, it looks overly complicated to me to use a "Data" class where a simple variable
>will do the trick, so I would suggest to change the code like this:
>
>pics = os.listdir(imgDir)
>pics.remove('license.txt')
>pics.remove('gacor.py')
>print "There are %s saved images in the image folder." % len(pics)
>pic = 0
>
>root = Tk()
>root.title("GaCoR Image Browser")
>app = Frame(root)
>app.grid()
>
>imgPrep = ImageTk.PhotoImage(file=os.path.join(imgDir, pics[pic]))
>imgShow = Label(app, image=imgPrep).grid()
>info = Label(app, text="Displaying %s" % pics[Data.pic])
>info.grid()
>
>def newPic():
>    global pic
>    pic = pic + 1
>    imgPrep.configure(file=os.path.join(imgDir, pics[pic]))
>    
>Button(app, text="Next Image", command=newPic).grid()
>Button(app, text="Close", command=quitProg).grid()
>app.mainloop()
>
>I hope this helps
>
>Michael
>
>
>  
>
Hi,

Unfortunately I get this error:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "Programming/Gacor/tmp.py", line 83, in newPic
imgPrep.configure(file=os.path.join(imgDir, pics[pic]))
AttributeError: PhotoImage instance has no attribute 'configure'

I think I should mention that I'm completely in the dark when it comes 
to GUI programming (and I don't have much time to learn it... or do I?)

Thanks for the help so far,
Joe


More information about the Tutor mailing list