Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove window background in Tkinter Python

I have seen many other threads about tkinter and having a transparent background on an image, and that's not exactly what I am looking for, so I decided to post my own question. I am making a clock that will look like its from the wallpaper, but I need it to be just numbers, and I wanted to know how to remove the window background.

from tkinter import *
import time
import sys

master = Tk()
master.title("Clock")

master.overrideredirect(1)

def get_time():
    timeVar = time.strftime("%I:%M:%S %p")
    clock.config(text=timeVar)
    clock.after(200,get_time)

clock = Label(master, font=("Calibri", 70),bg="black",fg="blue")
clock.pack()

get_time()

master.mainloop()
like image 676
BlueCircle_ Avatar asked Oct 28 '25 04:10

BlueCircle_


1 Answers

I think I understand what you want to do... For that you can use attributes("-transparent", "black") ---> ("-transparent", "color you want to make transparent")

from tkinter import *
import time
import sys

master = Tk()
master.title("Clock")

master.overrideredirect(1)
master.attributes("-transparent", "black")

def get_time():
    timeVar = time.strftime("%I:%M:%S %p")
    clock.config(text=timeVar)
    clock.after(200,get_time)

clock = Label(master, font=("Calibri", 70),bg="black",fg="blue")
clock.pack()

get_time()

master.mainloop()
like image 99
Cristielson Silva Avatar answered Oct 29 '25 18:10

Cristielson Silva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!