python编写窗口怎么清除内容 您所在的位置:网站首页 tkinter清空label中的图片 python编写窗口怎么清除内容

python编写窗口怎么清除内容

2024-07-14 23:44| 来源: 网络整理| 查看: 265

这个tkinter代码没有小部件,只有一个标签,所以它只在屏幕上显示一个文本,所以我想在一段时间后销毁或删除标签!,当方法标签.after(1000,label.destroy)不起作用时,我该怎么做???import tkinter, win32api, win32con, pywintypes

label = tkinter.Label(text='Text on the screen', font=('Times New Roman','80'), fg='black', bg='white')

label.master.overrideredirect(True)

label.master.geometry("+250+250")

label.master.lift()

label.master.wm_attributes("-topmost", True)

label.master.wm_attributes("-disabled", True)

label.master.wm_attributes("-transparentcolor", "white")

hWindow = pywintypes.HANDLE(int(label.master.frame(), 16))

# http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx

# The WS_EX_TRANSPARENT flag makes events (like mouse clicks) fall through the window.

exStyle = win32con.WS_EX_COMPOSITED | win32con.WS_EX_LAYERED | win32con.WS_EX_NOACTIVATE | win32con.WS_EX_TOPMOST | win32con.WS_EX_TRANSPARENT

win32api.SetWindowLong(hWindow, win32con.GWL_EXSTYLE, exStyle)

label.pack()

label.after(1000 , lambda: label.destroy()) #doesn't work anyway..

label.mainloop()



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有