Python Forum
[Tkinter] How do I change an image dynamically
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How do I change an image dynamically
#7
(May-28-2020, 08:50 PM)selmansem Wrote: Try this...

from tkinter import *
from tkinter import ttk

def TestLogic():
    stgImg = PhotoImage(file="Stage1.gif")
    label.configure(image=stgImg)
    label.image = stgImg

root = Tk()

root.geometry('1010x740+200+200')
 
stgImg = PhotoImage(file="Stage0.gif")
label=ttk.Label(root, image=stgImg)
label.place(x=400, y=400)
 
testBtn=ttk.Button(root, text="TEST", command=TestLogic)
testBtn.place(x=400, y=200)
root.mainloop()


It is working.

But what is the logic behind
"label.image = stgImg " this command.

Only this command makes it work. It is completely new addition when compared with text update.
Reply


Messages In This Thread
How do I change an image dynamically - by LeeMadeux - Jan-25-2018, 08:49 PM
RE: How do I change an image dynamically - by moorthypnt - Jun-04-2020, 09:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Tkinter don't change the image DQT 2 1,698 Jul-22-2022, 10:26 AM
Last Post: menator01
  How to dynamically change radiobutton text kenwatts275 2 3,418 Mar-05-2021, 02:25 AM
Last Post: deanhystad
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 13,850 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  [WxPython] wx.StaticBitmap change image royer14 4 8,441 Jul-02-2018, 02:35 PM
Last Post: royer14

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020