]>
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 self
. sizeChanged
= false
14 EVT_SIZE ( self
, self
. OnSize
)
15 EVT_IDLE ( self
, self
. OnIdle
)
17 self
. SetStatusText ( "A Custom StatusBar..." , 0 )
19 self
. cb
= wxCheckBox ( self
, 1001 , "toggle clock" )
20 EVT_CHECKBOX ( self
, 1001 , self
. OnToggleClock
)
21 self
. cb
. SetValue ( true
)
23 # set the initial position of the checkbox
27 self
. timer
= wxPyTimer ( self
. Notify
)
28 self
. timer
. Start ( 1000 )
34 t
= time
. localtime ( time
. time ())
35 st
= time
. strftime ( " %d-% b-%Y %I:%M:%S" , t
)
36 self
. SetStatusText ( st
, 2 )
37 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 def OnSize ( self
, evt
):
50 self
. Reposition () # for normal size events
52 # Set a flag so the idle time handler will also do the repositioning.
53 # It is done this way to get around a buglet where GetFieldRect is not
54 # accurate during the EVT_SIZE resulting from a frame maximize.
55 self
. sizeChanged
= true
58 def OnIdle ( self
, evt
):
63 # reposition the checkbox
65 rect
= self
. GetFieldRect ( 1 )
66 self
. cb
. SetPosition ( wxPoint ( rect
. x
+ 2 , rect
. y
+ 2 ))
67 self
. cb
. SetSize ( wxSize ( rect
. width
- 4 , rect
. height
- 4 ))
68 self
. sizeChanged
= false
72 class TestCustomStatusBar ( wxFrame
):
73 def __init__ ( self
, parent
, log
):
74 wxFrame
.__ init
__ ( self
, parent
, - 1 , 'Test Custom StatusBar' ,
75 wxPoint ( 0 , 0 ), wxSize ( 500 , 300 ))
76 wxWindow ( self
, - 1 ). SetBackgroundColour ( wxNamedColour ( "WHITE" ))
78 self
. sb
= CustomStatusBar ( self
, log
)
79 self
. SetStatusBar ( self
. sb
)
80 EVT_CLOSE ( self
, self
. OnCloseWindow
)
82 def OnCloseWindow ( self
, event
):
87 #---------------------------------------------------------------------------
89 def runTest ( frame
, nb
, log
):
90 win
= TestCustomStatusBar ( frame
, log
)
94 #---------------------------------------------------------------------------
105 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.