如何在Tkinter Python中移除窗口背景

4

我看到很多有关tkinter和在图片上设置透明背景的帖子,但那不是我要找的,所以我决定发表自己的问题。我正在制作一个看起来像壁纸的时钟,但我只需要数字,想知道如何去除窗口背景。

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()
1个回答

2
我认为我理解您想要做什么...为此,您可以使用属性("-transparent","黑色") ---> ("-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()

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接