Re: update image on pressing button

Michael Lange <[email protected]>
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
Hi,

On Wed, 29 Oct 2014 13:08:04 +0530
rajat das <[email protected]> wrote:

> Dear All,
> 
> I am new in python programming, kindly help me out.
> 
> *Problem:  *Basically as user press the "Next image button" the image
> should get refreshed by the next image from the specified path and so
> on. The problem is on pressing the button the image is coming below of
> the previous image not on top of it. Basically I want the images should
> slide on pressing the next button.
(...)
> def Click():
> 
>     image = Image.open("C:/Users/Slide2.bmp")
>     photo = ImageTk.PhotoImage(image)
> 
>     label = Label(root,image=photo)
>     label.image = photo # keep a reference!
>     label.pack()

the problem with your code is that instead of changing the image data of
the existing label widget you create a new Label. In your Click() function
you should simply do

    label.configure(image=photo)

instead of creating a new label.

I hope this helps

Michael

.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Humans do claim a great deal for that particular emotion (love).
		-- Spock, "The Lights of Zetar", stardate 5725.6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.