Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Refresh image in label after every 1s using simple function
#1
I am trying to refresh the Label Image after every 1s I have created one class in which only one time I 'll click on the button to display the image and after that, it will refresh after every second but unable to make that work

Earlier I was trying to make it work with canvas but it wasn't helping me out by showing it through label but was able to refresh using

self.canvas.after(100, self.loopCap)
but now in a label widget, I am not able to understand how refreshing the label every time

Code for is mentioned below:
class PageTwo(tk.Frame):
    def loopCap(self):
        # self.label = Label(self.master, image=self.img, textvariable=self.text)
        self.img = Image.open("img.jpg")
        self.label = ImageTk.PhotoImage(self.img)
        tk.Label(self, image=self.label).pack()
        print("updated")

    def __init__(self, master):
        tk.Frame.__init__(self, master,bg='powder blue')
        self.master.geometry('1350x750+0+0')
        self.master.config(bg='powder blue')
        tk.Button(self, text="Return to start page",
                  command=self.loopCap).pack()
        print("Load")
Suggestions will be much appreciated
Quote
#2
you can use the tkinter after method
see: https://effbot.org/tkinterbook/widget.htm
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Unable to update or refresh label text in tkinter jenkins43 3 281 Jul-24-2019, 02:09 PM
Last Post: Friend
  Simple Button click on image file to create action? jpezz 4 405 Mar-27-2019, 10:08 PM
Last Post: jpezz
  Tkinter refresh eduardoforo 4 1,398 Nov-14-2018, 09:35 PM
Last Post: woooee
  [Tkinter] Label doesn't refresh jollydragon 7 1,696 Jul-13-2018, 05:55 AM
Last Post: jollydragon
  [PyQt] enviremont refresh duende 2 923 May-13-2018, 09:49 AM
Last Post: duende
  pyqt main window refresh poblems duende 0 1,505 Apr-13-2018, 05:05 PM
Last Post: duende
  Refresh test in urwid.Text Stensborg 1 1,450 Mar-05-2018, 11:23 AM
Last Post: Stensborg
  [Tkinter] problem with refresh UI in tkinter app Philbot 5 3,457 Feb-06-2018, 01:10 PM
Last Post: Philbot
  How Can I Do Refresh Window? satrancali 0 2,669 Feb-03-2018, 07:50 AM
Last Post: satrancali

Forum Jump:


Users browsing this thread: 1 Guest(s)