![](/img/trans.png)
[英]How to customize pybusyinfo window in (windows OS) to make it appear at top corner of window and the other formatting options?
[英]Opening a window on top of other windows
如何在调用 function 时在其他 windows 之上打开一个 window?
import wx
def openFile(wildcard="*"):
app = wx.App(None)
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
dialog = wx.FileDialog(None, 'Open', wildcard=wildcard, style=style)
if dialog.ShowModal() == wx.ID_OK:
path = dialog.GetPath()
else:
dialog.Destroy()
path = 'No file'
return f'<div class="notification error">{path}</div>'
dialog.Destroy()
return f'<div id="pathToFile" class="notification">{path}</div>'
要在其他顶级 window 之上显示一个对话框,您需要将 window 指定为对话框父级(而不是像您那样使用None
)。
不支持在所有 windows 之上显示原生对话框,例如“打开文件”对话框,这只能使用wx.STAY_ON_TOP
标志为自定义 windows 完成。
@VZ 接受的答案适用于所有正常使用,但严格来说,您的代码可以调整以工作,即使它没有真正的用途,但您会注意到,尽管通过wx.STAY_ON_TOP
,它不会兑现它。
像这样:
import wx
def openFile(wildcard="*"):
app = wx.App(None)
style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.STAY_ON_TOP
dialog = wx.FileDialog(None, 'Open', wildcard=wildcard, style=style)
if dialog.ShowModal() == wx.ID_OK:
path = dialog.GetPath()
else:
path = 'No file'
dialog.Destroy()
return f'<div class="notification error">{path}</div>'
print(openFile())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.