2016-06-28 23 views
1

我有一個應用程序生成一個包含進度條的彈出窗口。下面是與彈出窗口相關的代碼。我想強制這個彈出窗口停留在產生這個窗口的應用程序之上。我嘗試使用wx.STAY_ON_TOP,但使用這種風格強制彈出窗口留在所有應用程序的頂部,這不是我想要的。任何意見/建議,將不勝感激!wxpython:如何使彈出窗口停留在當前應用程序的頂部

class ProgressBar(wx.Frame): 
    def __init__(self, parent): 
     wx.Frame.__init__(self, None, title="In progress...", 
         size=(300, 125))   
     GridBagSizer = wx.GridBagSizer() 
     TextFont = wx.Font(pointSize = 9, family = wx.SWISS, style = wx.NORMAL, weight = wx.NORMAL, faceName = 'Tahoma') 

     self.SetBackgroundColour('white') 
     self.gauge = wx.Gauge(self, range = 100, size = (-1, 30), style = wx.GA_HORIZONTAL, name = 'In Progress') 
     self.gauge.SetValue(0) 
     GridBagSizer.Add(self.gauge, pos = (0, 0), span = (1, 1), flag = wx.EXPAND|wx.ALL, border = 15) 

     self.txt = wx.StaticText(self, label = 'Retrieving data...', style = wx.ALIGN_CENTER) 
     self.txt.SetFont(TextFont) 
     box = wx.BoxSizer(wx.HORIZONTAL) 
     box.Add(self.txt, 0, wx.CENTER) 
     GridBagSizer.Add(box, pos = (1, 0), span = (1, 1), 
        flag = wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 
        border = 15) 

     GridBagSizer.AddGrowableCol(0) 
     #GridBagSizer.AddGrowableCol(1) 

     self.SetSizer(GridBagSizer) 
     self.SetMinSize((300, 125)) 
     self.SetMaxSize((300, 125)) 
     self.Layout() 
     self.Center() 

    def Update(self, step):   
     self.gauge.SetValue(step) 
     if step == 100: 
      self.Close() 

    def SetLabel(self, label): 
     self.txt.SetLabel(label) 
     self.Refresh() 
     self.Layout() 

回答

0

使用風格wx.FRAME_FLOAT_ON_PARENT

class ProgressBar(wx.Frame): 
    def __init__(self, parent): # you must set the parent ... 
     wx.Frame.__init__(self, parent, title="In progress...", 
         size=(300, 125),style=wx.FRAME_FLOAT_ON_PARENT) 
     ...  

,如果你想讓它有默認的框架的東西,你可以做

style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT 
相關問題