]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ContextHelp.py
1 # 11/4/2003 - grimmtooth@softhome.net (Jeff Grimmett)
5 # 11/24/2003 - grimmtooth@softhome.net (Jeff Grimmett)
7 # o Removed import of wx.help - now part of wx.core.
12 #----------------------------------------------------------------------
13 # We first have to set an application-wide help provider. Normally you
14 # would do this in your app's OnInit or in other startup code...
16 provider
= wx
. SimpleHelpProvider ()
17 wx
. HelpProvider_Set ( provider
)
19 # This panel is chock full of controls about which we can demonstrate the
21 class TestPanel ( wx
. Panel
):
22 def __init__ ( self
, parent
, log
):
23 wx
. Panel
.__ init
__ ( self
, parent
, - 1 )
26 # This help text, set for the panel itself, will be used if context
27 # sensitive help cannot be found for any particular control.
28 self
. SetHelpText ( "This is a wx.Panel." )
30 sizer
= wx
. BoxSizer ( wx
. VERTICAL
)
32 # Init the context help button.
33 # And even include help text about the help button :-)
34 cBtn
= wx
. ContextHelpButton ( self
)
35 cBtn
. SetHelpText ( "wx.ContextHelpButton" )
37 cBtnText
= wx
. StaticText ( self
, - 1 ,
38 "This is a wx.ContextHelpButton. Clicking it puts the \n "
39 "app into context sensitive help mode."
42 # Yes, even static text can have help text associated with it :-)
43 cBtnText
. SetHelpText ( "Some helpful text..." )
45 s
= wx
. BoxSizer ( wx
. HORIZONTAL
)
46 s
. Add ( cBtn
, 0 , wxALL
, 5 )
47 s
. Add ( cBtnText
, 0 , wxALL
, 5 )
51 # A text control with help text.
52 text
= wx
. TextCtrl ( self
, - 1 , "Each sub-window can have its own help message" ,
53 size
=( 240 , 60 ), style
= wx
. TE_MULTILINE
)
54 text
. SetHelpText ( "This is my very own help message. This is a really long long long long long long long long long long long long long long long long long long long long message!" )
58 # Same thing, but this time to demonstrate how the help event can be
60 text
= wx
. TextCtrl ( self
, - 1 , "You can also intercept the help event if you like. Watch the log window when you click here..." ,
61 size
=( 240 , 60 ), style
= wx
. TE_MULTILINE
)
62 text
. SetHelpText ( "Yet another context help message." )
65 self
. Bind ( wx
. EVT_HELP
, self
. OnCtxHelp
, text
)
67 text
= wx
. TextCtrl ( self
, - 1 , "This one displays the tip itself..." ,
68 size
=( 240 , 60 ), style
= wx
. TE_MULTILINE
)
71 self
. Bind ( wx
. EVT_HELP
, self
. OnCtxHelp2
, text
)
74 border
= wx
. BoxSizer ( wx
. VERTICAL
)
75 border
. Add ( sizer
, 0 , wx
. ALL
, 25 )
77 self
. SetAutoLayout ( True )
82 # On the second text control above, we intercept the help event. This is where
83 # we process it. Anything could happen here. In this case we're just printing
84 # some stuff about it, then passing it on, at which point we see the help tip.
85 def OnCtxHelp ( self
, evt
):
86 self
. log
. write ( "OnCtxHelp: %s " % evt
)
89 # On the third text control above, we intercept the help event.
90 # Here, we print a note about it, generate our own tip window, and,
91 # unlike last time, we don't pass it on to the underlying provider.
92 def OnCtxHelp2 ( self
, evt
):
93 self
. log
. write ( "OnCtxHelp: %s \n " % evt
)
94 tip
= wx
. TipWindow ( self
, "This is a wx.TipWindow" )
97 #----------------------------------------------------------------------
99 def runTest ( frame
, nb
, log
):
100 win
= TestPanel ( nb
, log
)
104 #----------------------------------------------------------------------
108 This demo shows how to incorporate Context Sensitive
109 help into your application using the wx.SimpleHelpProvider class.
113 #----------------------------------------------------------------------
115 if __name__
== '__main__' :
118 run
. main ([ '' , os
. path
. basename ( sys
. argv
[ 0 ])])