Nerdegutta's logo

nerdegutta.no

Python: New fullscreen python clock with tkinter

31.12.25

Programming

I've made a new updated version from this: How to make a clock in Python and Tkinter

# Import libraries
from tkinter import *
import time

# Function definitions
def tick():
    time_string=time.strftime("%H:%M")
    clock.config(text=time_string)
    clock.after(200, tick)

# Make the main window
window = Tk()

# Get the actual screen width and height
screenWidth = window.winfo_screenwidth()
screenHeight = window.winfo_screenheight()

# Set the window size from the variables
window.geometry(f"{screenWidth}x{screenHeight}")

# Remove the standard window decoration
window.overrideredirect(True)

# Set the window background
window.configure(bg="black")

# Make a label, and call it clock
clock = Label(window, font=("serif", 290, "bold"), fg="white", bg="black")

# Placing the label
clock.place(relx=0.5, rely=0.5, anchor=CENTER)

# Make a Quit buttton, and place it in top left corner
quitButton = Button(window, text="X", fg="red", command=window.destroy)
quitButton.pack(side=TOP, ancho=NW)

# Call the function tick()
tick()

# Disabling the window resize function
window.resizable(False, False)

# Hiding the cursor
window.config(cursor="none")

# Run the program
window.mainloop()

I have it on a Raspberry Pi 3 model B, with a 7" Touch Display 2.

To make the script autostart, I did this: