2
#!/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()
上面的代码创建一个通知,带有timout。但是,在Windows上 - 通知不会自动弹出超过所有其他当前窗口。你必须点击杀死按钮(文本),并在第一次集中它,之后根窗口将显示在所有其他窗口之上。使tkinter窗口出现在所有其他窗口上
有没有办法使通知自动出现在所有其他窗口之上 - 在Windows上?
它似乎在linux上工作得很好(Ubuntu 9.10)。
我不认为这适用于osx? –
不知道......我没有做太多的OSX。然而,刚刚在OSX 10.5.8上使用Python 2.6.5进行了测试,并得到一个错误'''_tkinter.TclError:错误的选项“-topmost”:必须是-modified或-titlepath'''。不管什么意思。 –
是的,我认为这个技巧只适用于Windows?它在Linux上工作吗? –