• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Tkinter Clock


Silver Coder
Haven't posted in a while so, here is a simple tkinter clock

import tkinter as tk
from time import strftime

class Window:
    def __init__(self, parent):
        self.parent = parent
        self.label = tk.Label(parent, text='', bg='black', fg='red')
        self.label['highlightbackground'] = 'lightgray'
        self.label['highlightcolor'] = 'lightgray'
        self.label['highlightthickness'] = 3
        self.label.pack(expand=True, fill='both', padx=5, pady=3)

    def update(self):
        clock = strftime('%H:%M:%S')
        self.label['text'] = clock
        self.label['font'] = (None, 36, 'normal')
        self.parent.after(1000, self.update)

if __name__ == '__main__':
    root = tk.Tk()
    root.title('Tkinter Clock')

New Threads

Latest posts

Buy us a coffee!

Top Bottom