Python Forum
Tkinter error for a scheduled event
Thread Rating:
  • 4 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter error for a scheduled event
#5
Hi Ceegen

Here is a working solution:
import time
import tkinter as tk

APP_TITLE = "The Time"

APP_XPOS = 100
APP_YPOS = 100
APP_WIDTH = 200
APP_HEIGHT = 100


class Application(object):

    def __init__(self, main_win):
        self.main_win = main_win
        
        self.time_var = tk.StringVar()
        self.build()
        
    def build(self):
        tk.Label(self.main_win, textvariable=self.time_var, width=10, fg='blue',
            font=('Helvetica', 30, 'bold')).pack(expand=True)
            
        self.update_time()
        
    def update_time(self):
        self.time_var.set(time.strftime('%H:%M:%S'))
        self.main_win.after(1000, self.update_time)
               
def main():
    main_win = tk.Tk()
    main_win.title(APP_TITLE)
    #main_win.geometry("+{}+{}".format(APP_XPOS, APP_YPOS))
    main_win.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT))
    
    app = Application(main_win)
    
    main_win.mainloop()
wuf Wink
Reply


Messages In This Thread
Tkinter error for a scheduled event - by Ceegen - Jan-12-2019, 04:43 AM
RE: Tkinter error for a scheduled event - by woooee - Jan-13-2019, 06:53 AM
RE: Tkinter error for a scheduled event - by Ceegen - Jan-14-2019, 05:20 AM
RE: Tkinter error for a scheduled event - by woooee - Jan-14-2019, 06:42 AM
RE: Tkinter error for a scheduled event - by wuf - Jan-14-2019, 07:59 AM
RE: Tkinter error for a scheduled event - by Ceegen - Jan-14-2019, 09:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Mouse click event not working on multiple tkinter window evrydaywannabe 2 3,898 Dec-16-2019, 04:47 AM
Last Post: woooee
  What is the purpose of "None" in event=None with tkinter ? alan9979 2 6,717 Jul-10-2019, 08:50 PM
Last Post: alan9979

Forum Jump:

User Panel Messages

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