![](/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.