制造wx.BusyInfo公司在wxpython保持领先

2024-09-29 23:17:33 发布

您现在位置:Python中文网/ 问答频道 /正文

用下面的例子,我怎么做wx.BusyInfo公司即使我打开另一个应用程序,也要掌握一切?在

import time
import wx

########################################################################
class MyForm(wx.Frame):

    #----------------------------------------------------------------------
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY,
                          "BusyDialog Tutorial")
        panel = wx.Panel(self, wx.ID_ANY)

        busyBtn = wx.Button(panel, label="Show Busy Dialog")
        busyBtn.Bind(wx.EVT_BUTTON, self.onBusy)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(busyBtn, 0, wx.ALL|wx.CENTER, 5)
        panel.SetSizer(sizer)

    #----------------------------------------------------------------------
    def onBusy(self, event):
        self.Hide()
        msg = "Please wait while we process your request..."
        busyDlg = wx.BusyInfo(msg)
        time.sleep(5)
        busyDlg = None
        self.Show()

# Run the program
if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()

Tags: importselfnoneidtimeinitdefshow
1条回答
网友
1楼 · 发布于 2024-09-29 23:17:33

根据Robin Dunn

The frame used by wx.BusyInfo only uses the stay on top flag if the parent window also has it.


def onBusy(self, event):
    self.Hide()
    msg = "Please wait while we process your request..."
    old_style = self.GetWindowStyle()
    self.SetWindowStyle(old_style | wx.STAY_ON_TOP)
    busyDlg = wx.BusyInfo(msg, self)
    time.sleep(5)
    busyDlg = None
    self.Show()
    self.SetWindowStyle(old_style)

相关问题 更多 >

    热门问题