让wx.BusyInfo在wxpython中保持领先

时间:2014-05-01 06:30:33

标签: python dialog wxpython

使用下面的示例,即使我打开另一个应用程序,如何使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()

1 个答案:

答案 0 :(得分:0)

根据Robin Dunn

  

wx.BusyInfo使用的帧仅使用逗号在顶部标记   父窗口也有它。


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)