在python中,我们可以通过定义创建弹出窗口
def pop(msg):
MessageBox = ctypes.windll.user32.MessageBoxW
MessageBox(None, msg, 'Window title', 0)
然后
pop('some message')
将显示一个弹出窗口以通知用户。
但是如何使此弹出窗口位于所有其他窗口之上,以使用户绝对不会错过它?
答案 0 :(得分:1)
尝试:
at org.apache.hadoop.fs.RawLocalFileSystem.deprecatedGetFileStatus(RawLocalFileSystem.java:611)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileLinkStatusInternal(RawLocalFileSystem.java:824)
at org.apache.hadoop.fs.RawLocalFileSystem.getFileStatus(RawLocalFileSystem.java:601)
at org.apache.hadoop.fs.FilterFileSystem.getFileStatus(FilterFileSystem.java:428)
at org.apache.hadoop.yarn.util.FSDownload.copy(FSDownload.java:253)
at org.apache.hadoop.yarn.util.FSDownload.access$000(FSDownload.java:63)
at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:361)
at org.apache.hadoop.yarn.util.FSDownload$2.run(FSDownload.java:359)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:421)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1762)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:358)
at org.apache.hadoop.yarn.util.FSDownload.call(FSDownload.java:62)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:473)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at java.lang.Thread.run(Thread.java:748)
答案 1 :(得分:0)
使用tkinter可能是一个更好的主意-除了它是python的一部分之外,它也是跨平台的。
以下是弹出的示例:
from tkinter import messagebox, Toplevel, Label, Tk, Button
def pop(msg): # This will be on top of the window which called this pop up
messagebox.showinfo('message', msg)
def pop_always_on_top(msg): # This will be on top of any other window
msg_window = Toplevel()
msg_window.title("Show Message")
msg_window.attributes('-topmost', True)
msg_label = Label(msg_window, text=msg)
msg_label.pack(expand=1, fill='both')
button = Button(msg_window, text="Ok", command=msg_window.destroy)
button.pack()
if __name__ == '__main__':
top = Tk()
hello_btn = Button(top, text="Say Hello", command=lambda: pop('hello world!'))
hello_btn.pack()
hello_btn = Button(top, text="Say Hello and stay on top!", command=lambda: pop_always_on_top('hello world - on top!'))
hello_btn.pack()
top.mainloop()
该消息框自动位于其父窗口的顶部。
如果要使其位于系统上其他所有窗口的顶部,请设置窗口的“ -topmost”标志(如第二种方法所示)。