from tkinter import *
parent = Tk()
parent.geometry('500x500')
parent.title('Test in progress...')
parent.attributes('-alpha',0.5)
#parent.attributes('-fullscreen', True)
button1 = Button(parent, text = 'FOUND!',fg='red', command=parent.destroy)
button1.pack()
parent.mainloop()
我希望它在全屏上閃爍半透明紅色而不影響用戶選擇事物的能力。
uj5u.com熱心網友回復:
使用這個答案的一些幫助,我想我可以幫助你。你需要有一個函式來控制顏色的變化.after。它以類似“閃爍”的方式從白色透明變為紅色。我希望這是你想要的。
from tkinter import *
def change_color():
current_color = parent.cget("bg")
next_color = "white" if current_color == "red" else "red"
parent.config(background=next_color)
parent.after(1000, change_color)
parent = Tk()
parent.config(bg="red")
parent.attributes('-alpha', 0.5)
parent.geometry('500x500')
parent.title('Test in progress...')
button1 = Button(parent, text='FOUND!', fg='red', command=parent.destroy)
button1.pack()
change_color()
parent.mainloop()
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/483750.html
