]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxStatusBar.py
2 from wxPython
. wx
import *
6 #---------------------------------------------------------------------------
8 class CustomStatusBar ( wxStatusBar
):
9 def __init__ ( self
, parent
, log
):
10 wxStatusBar
.__ init
__ ( self
, parent
, - 1 )
11 self
. SetFieldsCount ( 3 )
13 EVT_SIZE ( self
, self
. OnSize
)
15 self
. SetStatusText ( "A Custom StatusBar..." , 0 )
17 self
. cb
= wxCheckBox ( self
, 1001 , "toggle clock" )
18 EVT_CHECKBOX ( self
, 1001 , self
. OnToggleClock
)
19 self
. cb
. SetValue ( true
)
21 # figure out how tall to make it.
23 dc
. SetFont ( self
. GetFont ())
24 ( w
, h
) = dc
. GetTextExtent ( 'X' )
26 self
. SetSize ( wxSize ( 100 , h
))
29 self
. timer
= wxPyTimer ( self
. Notify
)
30 self
. timer
. Start ( 1000 )
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 " )
41 # the checkbox was clicked
42 def OnToggleClock ( self
, event
):
43 if self
. cb
. GetValue ():
44 self
. timer
. Start ( 1000 )
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 ))
58 class 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" ))
64 self
. sb
= CustomStatusBar ( self
, log
)
65 self
. SetStatusBar ( self
. sb
)
66 EVT_CLOSE ( self
, self
. OnCloseWindow
)
68 def OnCloseWindow ( self
, event
):
73 #---------------------------------------------------------------------------
75 def runTest ( frame
, nb
, log
):
76 win
= TestCustomStatusBar ( frame
, log
)
80 #---------------------------------------------------------------------------
91 A 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.
94 ----------------------------
98 wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
100 Constructor, creating the window.
105 parent = The window parent, usually a frame.
107 id = The window identifier. It may take a value of -1 to indicate a default value.
109 pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
111 size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
113 style = The window style. See wxStatusBar.
115 name = 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.