How to create a status bar (Phoenix)
Keywords : Status bar.
Contents
Introduction :
As its name indicates, the wx.StatusBar widget is used to display application status information.
It can be divided into several parts to show different kind of information.
We can insert other widgets into the wx.StatusBar.
It can be used as an alternative to dialogs, since dialogs are ofted abused and are disliked by most users.
We can create a wx.StatusBar in two ways.
We can manually create our own wx.StatusBar and call SetStatusBar() method or we can simply call a CreateStatusBar() method.
The latter method creates a default wx.StatusBar for us.
In our first example, we have a wx.Frame widget and five other widgets.
If we hover a mouse pointer over a widget, its description is shown on the wx.StatusBar.
(info by ZetCode / Jan Bodnar).
Demonstrating :
Tested py3.x, wx4.x and Win10.
Are you ready to use some samples ?
Test, modify, correct, complete, improve and share your discoveries !
Sample one
1 # sample_one.py
2
3 """
4
5 Author : Jan Bodnar
6 Website : zetcode.com
7
8 """
9
10 import wx
11
12 # class MyFrame
13 # class MyApp
14
15 #---------------------------------------------------------------------------
16
17 class MyFrame(wx.Frame):
18 def __init__(self, parent, id, title):
19 wx.Frame.__init__(self, parent, id, title, size=(300, 230),
20 style=wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX)
21
22 self.SetIcon(wx.Icon('./icons/wxwin.ico', wx.BITMAP_TYPE_ICO))
23 self.SetMaxSize((300, 230))
24 self.SetMinSize((300, 230))
25
26 #------------
27
28 panel = wx.Panel(self, 1)
29
30 button = wx.Button(panel, 2, '&Button', (20, 20))
31 text = wx.CheckBox(panel, 3, 'CheckBox', (20, 90))
32 combo = wx.ComboBox(panel, 4, '', (120, 22))
33 slider = wx.Slider(panel, 5, 6, 1, 10, (120, 90), (110, -1))
34
35 #------------
36
37 panel.Bind(wx.EVT_ENTER_WINDOW, self.EnterPanel, id=1)
38 button.Bind(wx.EVT_ENTER_WINDOW, self.EnterButton, id=2)
39 text.Bind(wx.EVT_ENTER_WINDOW, self.EnterText, id=3)
40 combo.Bind(wx.EVT_ENTER_WINDOW, self.EnterCombo, id=4)
41 slider.Bind(wx.EVT_ENTER_WINDOW, self.EnterSlider, id=5)
42
43 #------------
44
45 self.sb = self.CreateStatusBar()
46
47 #------------
48
49 self.Centre()
50
51 #-----------------------------------------------------------------------
52
53 def EnterButton(self, event):
54 self.sb.SetStatusText('Button widget')
55 event.Skip()
56
57
58 def EnterPanel(self, event):
59 self.sb.SetStatusText('Panel widget')
60 event.Skip()
61
62
63 def EnterText(self, event):
64 self.sb.SetStatusText('CheckBox widget')
65 event.Skip()
66
67
68 def EnterCombo(self, event):
69 self.sb.SetStatusText('ComboBox widget')
70 event.Skip()
71
72
73 def EnterSlider(self, event):
74 self.sb.SetStatusText('Slider widget')
75 event.Skip()
76
77 #---------------------------------------------------------------------------
78
79 class MyApp(wx.App):
80 def OnInit(self):
81 frame = MyFrame(None, -1, 'wx.StatusBar')
82 frame.Show(True)
83
84 return True
85
86 #---------------------------------------------------------------------------
87
88 def main():
89 app = MyApp(redirect=False)
90 app.MainLoop()
91
92 #---------------------------------------------------------------------------
93
94 if __name__ == "__main__" :
95 main()
Download source
Additional Information
Link :
- - - - -
https://wiki.wxpython.org/TitleIndex
Thanks to
Jan Bodnar (sample_one.py coding), the wxPython community...
About this page
Date(d/m/y) Person (bot) Comments :
30/12/20 - Ecco (Created page for wxPython Phoenix).
Comments
- blah, blah, blah....