]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/wxStatusBar.py
Committing in .
[wxWidgets.git] / wxPython / demo / wxStatusBar.py
CommitLineData
cf694132
RD
1
2from wxPython.wx import *
3
4import time
5
6#---------------------------------------------------------------------------
7
8class CustomStatusBar(wxStatusBar):
9 def __init__(self, parent, log):
10 wxStatusBar.__init__(self, parent, -1)
11 self.SetFieldsCount(3)
12 self.log = log
f6bcfd97 13 EVT_SIZE(self, self.OnSize)
cf694132
RD
14
15 self.SetStatusText("A Custom StatusBar...", 0)
16
17 self.cb = wxCheckBox(self, 1001, "toggle clock")
18 EVT_CHECKBOX(self, 1001, self.OnToggleClock)
19 self.cb.SetValue(true)
20
21 # figure out how tall to make it.
22 dc = wxClientDC(self)
23 dc.SetFont(self.GetFont())
24 (w,h) = dc.GetTextExtent('X')
25 h = int(h * 1.8)
26 self.SetSize(wxSize(100, h))
27
28 # start our timer
29 self.timer = wxPyTimer(self.Notify)
30 self.timer.Start(1000)
31 self.Notify()
32
33
34 # Time-out handler
35 def Notify(self):
36 t = time.localtime(time.time())
37 st = time.strftime("%d-%b-%Y %I:%M:%S", t)
38 self.SetStatusText(st, 2)
39 self.log.WriteText("tick...\n")
40
41 # the checkbox was clicked
42 def OnToggleClock(self, event):
43 if self.cb.GetValue():
44 self.timer.Start(1000)
45 self.Notify()
46 else:
47 self.timer.Stop()
48
49
50 # reposition the checkbox
51 def OnSize(self, event):
52 rect = self.GetFieldRect(1)
53 self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
54 self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
55
56
57
58class TestCustomStatusBar(wxFrame):
59 def __init__(self, parent, log):
60 wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
61 wxPoint(0,0), wxSize(500, 300))
62 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
63
64 self.sb = CustomStatusBar(self, log)
65 self.SetStatusBar(self.sb)
f6bcfd97 66 EVT_CLOSE(self, self.OnCloseWindow)
cf694132
RD
67
68 def OnCloseWindow(self, event):
69 self.sb.timer.Stop()
70 del self.sb.timer
71 self.Destroy()
72
73#---------------------------------------------------------------------------
74
75def runTest(frame, nb, log):
76 win = TestCustomStatusBar(frame, log)
77 frame.otherWin = win
78 win.Show(true)
79
80#---------------------------------------------------------------------------
81
82
83
84
85
86
87
88
89
90overview = """\
91A status bar is a narrow window that can be placed along the bottom of a frame to give small amounts of status information. It can contain one or more fields, one or more of which can be variable length according to the size of the window.
92
93wxStatusBar()
94----------------------------
95
96Default constructor.
97
98wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
99
100Constructor, creating the window.
101
102Parameters
103-------------------
104
105parent = The window parent, usually a frame.
106
107id = The window identifier. It may take a value of -1 to indicate a default value.
108
109pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
110
111size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
112
113style = The window style. See wxStatusBar.
114
115name = The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.
116"""