The following code places progress bar in the 1st field of status bar:
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)
How to place progress bar in field no. 2 of status bar?
There's a nice custom extension of the status bar called the EnhancedStatusBar that you can find here: http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
It allows you add pretty much any widget to the status bar. Here's an example of adding a progress bar to the second field of the status bar using this widget:
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()
Tested with Python 2.6 / wxPython 2.8 and Python 2.7 / wxPython 2.9 on Windows 7. It doesn't appear to work with wxPython 3, however.