[Tutor] New image with Tkinter?
alan.gauld at freenet.co.uk
Mon Oct 10 23:22:54 CEST 2005
Data.pic += 1
imgPrep = ImageTk.PhotoImage(img)
imgShow = Label(app, image=imgPrep).grid()
next = Button(app, text="Next Image", command=newPic).grid()
> The image won't refresh when I click on 'Next'!
> Any help would be appreciated.
You never ask it to refresh. The GUI displays the image that you pass to it,
you then call newPic which only increments the data counter but does
nothing to change the image being displayed.
You need to make your Photoimage object visible to newPic
(by making it global say?) and then in newPic acyually update
the image being displayed. visible
BTW you seem to be callingmainloop within the DSpImage function,
thats probably a bad idea, mainloop should only be called once
which means you could never call DspImage a second time should
you ever need to...
Author of the learn to program web tutor
More information about the Tutor