tor*_*ger 2 python windows stack focus tkinter
#!/usr/bin/env python
# Display window with toDisplayText and timeOut of the window.
from Tkinter import *
def showNotification(notificationTimeout, textToDisplay):
## Create main window
root = Tk()
Button(root, text=textToDisplay, activebackground="white", bg="white", command=lambda: root.destroy()).pack(side=LEFT)
root.update_idletasks()
# Remove window decorations
root.overrideredirect(1)
timeOut = int(notificationTimeout*1000) # Convert to ms from s
## Run appliction
root.after(timeOut,root.destroy)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
上面的代码创建了一个带有提示的通知.但是在Windows上 - 通知不会自动弹出所有其他当前窗口.必须单击kill按钮(文本),并在第一次对焦,之后根窗口将显示在所有其他窗口上方.
有没有办法让通知自动出现在所有其他窗口之上 - 在Windows上?
它似乎在Linux上工作得很好(ubuntu 9.10).
根据此消息,您应该能够添加以下内容root.overridedirect(1).这里的快速测试表明它应该适合你.
root.wm_attributes("-topmost", 1)
Run Code Online (Sandbox Code Playgroud)