以下代码在状态栏的第一个字段中放置进度条:
self.statusbar = self.CreateStatusBar()
self.statusbar.SetFieldsCount(3)
self.statusbar.SetStatusWidths([320, -1, -2])
self.progress_bar = wx.Gauge(self.statusbar, -1, style=wx.GA_HORIZONTAL|wx.GA_SMOOTH)
如何在字段no中放置进度条。 2状态栏?
答案 0 :(得分:2)
状态栏的自定义扩展名为EnhancedStatusBar,您可以在此处找到:http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
它允许您将几乎任何小部件添加到状态栏。以下是使用此小部件向状态栏的第二个字段添加进度条的示例:
import EnhancedStatusBar
import wx
########################################################################
class MyPanel(wx.Panel):
""""""
#----------------------------------------------------------------------
def __init__(self, parent):
"""Constructor"""
wx.Panel.__init__(self, parent)
########################################################################
class MyFrame(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="Enhanced Statusbar Demo")
panel = MyPanel(self)
self.statusbar = EnhancedStatusBar.EnhancedStatusBar(self)
self.statusbar.SetSize((-1, 23))
self.statusbar.SetFieldsCount(2)
self.SetStatusBar(self.statusbar)
self.progress = wx.Gauge(self.statusbar, range=20)
self.statusbar.AddWidget(self.progress, pos=1)
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateGauge)
self.timer.Start(100)
#----------------------------------------------------------------------
def updateGauge(self, event):
""""""
self.progress.Pulse()
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
frame = MyFrame()
frame.Show()
app.MainLoop()
在Windows 7上使用Python 2.6 / wxPython 2.8和Python 2.7 / wxPython 2.9进行测试。然而,它似乎不适用于wxPython 3。