how to switch image in tkinter? making it mutable? how?

ChrisChia chrischia82 at gmail.com
Mon Aug 16 21:38:06 EDT 2010


On Aug 17, 2:57 am, Jeff  Hobbs <jeff.ho... at gmail.com> wrote:
> On Aug 16, 7:30 am, ChrisChia <chrischi... at gmail.com> wrote:
>
> > I have this:
> > image1 = ImageTk.PhotoImage(file = "c:\\f1.jpg")
> > image2 = ImageTk.PhotoImage(file = "c:\\f2.jpg")
>
> > imagelist.append(image1)
> > imagelist.append(image2)
>
> > self.label  = tk.Label(image = imagelist[0])
>
> > is there a way that i can create a method to switch the display the
> > image2 (imagelist 2nd element)
> > without using label.bind?
>
> > can i make an image mutable?
>
> self.label.configure(image = imagelist[1]) will change the image
> displayed.
> With PIL images, you can use image1.fromstring(...) that should have a
> similar effect, in that it changes the underlying image data and the
> label will display that.
>
> Whether you need to label.bind or something else to effect this change
> is up to you.  You could have it happen on a timer, triggered by an
> event, or randomly effected by solar flares, depending on your
> application's needs.
>
> Jeff

Yes... I don't intend to make it mutable anymore...
thanks to Jeff for the
self.label.configure

i don't even know about the configure method.
I m very new to tkinter.
Thanks everyone!!!



More information about the Python-list mailing list