Home > Back-end >  How to remove window background in Tkinter Python
How to remove window background in Tkinter Python

Time:09-28

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()

CodePudding user response:

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()

CodePudding user response:

Cristielson Silva, I replaced this line: master.attributes("-transparent", "black") With this: master.attributes("-alpha", 0.5)

  • Related