]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/demo/wxStatusBar.py
1. Grid cell defaults are now handled by an internal
[wxWidgets.git] / utils / 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
13
14 self.SetStatusText("A Custom StatusBar...", 0)
15
16 self.cb = wxCheckBox(self, 1001, "toggle clock")
17 EVT_CHECKBOX(self, 1001, self.OnToggleClock)
18 self.cb.SetValue(true)
19
20 # figure out how tall to make it.
21 dc = wxClientDC(self)
22 dc.SetFont(self.GetFont())
23 (w,h) = dc.GetTextExtent('X')
24 h = int(h * 1.8)
25 self.SetSize(wxSize(100, h))
26
27 # start our timer
28 self.timer = wxPyTimer(self.Notify)
29 self.timer.Start(1000)
30 self.Notify()
31
32
33 # Time-out handler
34 def Notify(self):
35 t = time.localtime(time.time())
36 st = time.strftime("%d-%b-%Y %I:%M:%S", t)
37 self.SetStatusText(st, 2)
38 self.log.WriteText("tick...\n")
39
40 # the checkbox was clicked
41 def OnToggleClock(self, event):
42 if self.cb.GetValue():
43 self.timer.Start(1000)
44 self.Notify()
45 else:
46 self.timer.Stop()
47
48
49 # reposition the checkbox
50 def OnSize(self, event):
51 rect = self.GetFieldRect(1)
52 self.cb.SetPosition(wxPoint(rect.x+2, rect.y+2))
53 self.cb.SetSize(wxSize(rect.width-4, rect.height-4))
54
55
56
57class TestCustomStatusBar(wxFrame):
58 def __init__(self, parent, log):
59 wxFrame.__init__(self, parent, -1, 'Test Custom StatusBar',
60 wxPoint(0,0), wxSize(500, 300))
61 wxWindow(self, -1).SetBackgroundColour(wxNamedColour("WHITE"))
62
63 self.sb = CustomStatusBar(self, log)
64 self.SetStatusBar(self.sb)
65
66 def OnCloseWindow(self, event):
67 self.sb.timer.Stop()
68 del self.sb.timer
69 self.Destroy()
70
71#---------------------------------------------------------------------------
72
73def runTest(frame, nb, log):
74 win = TestCustomStatusBar(frame, log)
75 frame.otherWin = win
76 win.Show(true)
77
78#---------------------------------------------------------------------------
79
80
81
82
83
84
85
86
87
88overview = """\
89A 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.
90
91wxStatusBar()
92----------------------------
93
94Default constructor.
95
96wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
97
98Constructor, creating the window.
99
100Parameters
101-------------------
102
103parent = The window parent, usually a frame.
104
105id = The window identifier. It may take a value of -1 to indicate a default value.
106
107pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
108
109size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
110
111style = The window style. See wxStatusBar.
112
113name = 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.
114"""