How to make the window completely transparent, but keep the components completely opaque #2607
Unanswered
maxwangwyf
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
"""simple clock"""
import customtkinter as ctk
from datetime import datetime
from time import strftime
import sys,os
import pywinstyles
from hPyT import *
from hPyT import *
def resource_path(relative_path):
"""获取打包后资源的路径"""
try:
# PyInstaller创建的临时文件夹
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
WIN = ctk.CTk()
WIN.maxsize(480, 120)
WIN.resizable(False, False)
WIN.title("DIGITAL CLOCK")
title_bar.hide(WIN)#无边框
ctk.FontManager.load_font(resource_path("fonts\Aaspot.ttf"))
FONT=ctk.CTkFont('字体管家波点',50)
FONT1= ctk.CTkFont('字体管家波点',10)
def stay_on_top():
WIN.lift()
WIN.after(2000, stay_on_top)
day = {
"MONDAY": "周一",
"TUESDAY": "周二",
"WEDNESDAY": "周三",
"THURSDAY": "周四",
"FRIDAY": "周五",
"SATURDAY": "周六",
"SUNDAY": "周日"
}
currday = day[datetime.today().strftime("%A").upper()]
frame = ctk.CTkFrame(WIN, width=750, height=200, fg_color="transparent", bg_color="transparent")
frame.pack(expand=True)
pywinstyles.set_opacity(frame, color='white')
def update_time():
currtime = strftime("%H : %M : %S")
label.configure(text= currtime)
label.after(1000, update_time)
label = ctk.CTkLabel(frame, font=FONT, fg_color="transparent", text_color="white")
label.place(x= 32, y=15)
update_time()
label1 = ctk.CTkLabel(frame, font=FONT, fg_color="transparent", text_color="white",text=" | "+currday)
label1.place(x=300, y=15)
label3=ctk.CTkLabel(frame, font=FONT1,fg_color='transparent',text_color='#7f7f7f',text='时')
label3.place(x=56, y=80)
label4=ctk.CTkLabel(frame, font=FONT1,fg_color='transparent',text_color='#7f7f7f',text='分')
label4.place(x=144, y=80)
label5=ctk.CTkLabel(frame, font=FONT1,fg_color='transparent',text_color='#7f7f7f',text='秒')
label5.place(x=240, y=80)
label2=ctk.CTkLabel(frame, font=FONT1,fg_color='transparent',text_color='#7f7f7f',text='天')
label2.place(x=392, y=80)
WIN.mainloop()
Beta Was this translation helpful? Give feedback.
All reactions