]>
git.saurik.com Git - wxWidgets.git/blob - utils/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 )
14 self
. SetStatusText ( "A Custom StatusBar..." , 0 )
16 self
. cb
= wxCheckBox ( self
, 1001 , "toggle clock" )
17 EVT_CHECKBOX ( self
, 1001 , self
. OnToggleClock
)
18 self
. cb
. SetValue ( true
)
20 # figure out how tall to make it.
22 dc
. SetFont ( self
. GetFont ())
23 ( w
, h
) = dc
. GetTextExtent ( 'X' )
25 self
. SetSize ( wxSize ( 100 , h
))
28 self
. timer
= wxPyTimer ( self
. Notify
)
29 self
. timer
. Start ( 1000 )
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 " )
40 # the checkbox was clicked
41 def OnToggleClock ( self
, event
):
42 if self
. cb
. GetValue ():
43 self
. timer
. Start ( 1000 )
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 ))
57 class 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" ))
63 self
. sb
= CustomStatusBar ( self
, log
)
64 self
. SetStatusBar ( self
. sb
)
66 def OnCloseWindow ( self
, event
):
71 #---------------------------------------------------------------------------
73 def runTest ( frame
, nb
, log
):
74 win
= TestCustomStatusBar ( frame
, log
)
78 #---------------------------------------------------------------------------
89 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.
92 ----------------------------
96 wxStatusBar(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "statusBar")
98 Constructor, creating the window.
103 parent = The window parent, usually a frame.
105 id = The window identifier. It may take a value of -1 to indicate a default value.
107 pos = The window position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxWindows, depending on platform.
109 size = The window size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxWindows, depending on platform.
111 style = The window style. See wxStatusBar.
113 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.