我有一个应用程序,它会生成一个包含进度条的弹出窗口。与弹出窗口相关的代码如下。我想强制这个弹出窗口保持在生成此窗口的应用程序的顶部。我尝试使用wx.STAY_ON_TOP
,但使用此样式会强制弹出窗口保持在所有应用程序之上,这不是我想要的。任何建议/意见将不胜感激!
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 :(得分: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