#!/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()
以上代码创建了一个带有超时的通知。然而,在Windows上,通知不会自动弹出到所有其他窗口的上方。第一次需要单击“kill”按钮(文本)并将其聚焦,之后根窗口将显示在所有其他窗口的上方。
有没有办法使通知在Windows上自动出现在所有其他窗口的上方?
在Linux上似乎运行得很好(Ubuntu 9.10)。