]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/wxd/Base.py
1 """Decorator classes for documentation and shell scripting.
4 __author__
= "Patrick K. O'Brien <pobrien@orbtech.com>"
6 __revision__
= "$Revision$"[11:-2]
9 # These are not the real wxPython classes. These are Python versions
10 # for documentation purposes. They are also used to apply docstrings
11 # to the real wxPython classes, which are SWIG-generated wrappers for
15 import Parameters
as wx
19 """Base class for all other wxPython classes."""
22 """Create a Object instance."""
26 """Destroy the Object instance."""
29 def GetClassName(self
):
30 """Return the name of the class."""
34 class EvtHandler(Object
):
35 """Base class that can handle events from the windowing system.
37 If the handler is part of a chain, the destructor will unlink
38 itself and restore the previous and next handlers so that they
39 point to each other."""
42 """Create a EvtHandler instance."""
45 def AddPendingEvent(self
, event
):
46 """Post an event to be processed later.
48 event is an Event instance to add to process queue.
50 The difference between sending an event (using the
51 ProcessEvent method) and posting it is that in the first case
52 the event is processed before the function returns, while in
53 the second case, the function returns immediately and the
54 event will be processed sometime later (usually during the
55 next event loop iteration).
57 A copy of event is made by the function, so the original can
58 be deleted as soon as function returns (it is common that the
59 original is created on the stack). This requires that the
60 Event::Clone method be implemented by event so that it can
61 be duplicated and stored until it gets processed.
63 This is also the method to call for inter-thread
64 communication. It will post events safely between different
65 threads which means that this method is thread-safe by using
66 critical sections where needed. In a multi-threaded program,
67 you often need to inform the main GUI thread about the status
68 of other working threads and such notification should be done
71 This method automatically wakes up idle handling if the
72 underlying window system is currently idle and thus would not
73 send any idle events. (Waking up idle handling is done
74 calling WakeUpIdle.)"""
77 def Connect(self
, id, lastId
, eventType
, func
):
78 """Connects the given function dynamically with the event
79 handler, id and event type. This is an alternative to the use
80 of static event tables.
82 id is the identifier (or first of the identifier range) to be
83 associated with the event handler function.
85 lastId is the second part of the identifier range to be
86 associated with the event handler function.
88 eventType is the event type to be associated with this event
91 function is the event handler function.
93 userData is data to be associated with the event table entry."""
96 def Disconnect(self
, id, lastId
=-1, eventType
=wx
.EVT_NULL
):
97 """Disconnects the given function dynamically from the event
98 handler, using the specified parameters as search criteria and
99 returning True if a matching function has been found and
100 removed. This method can only disconnect functions which have
101 been added using the EvtHandler.Connect method. There is no
102 way to disconnect functions connected using the (static) event
105 id is the identifier (or first of the identifier range) to be
106 associated with the event handler function.
108 lastId is the second part of the identifier range to be
109 associated with the event handler function.
111 eventType is the event type to be associated with this event
114 function is the event handler function.
116 userData is data to be associated with the event table entry."""
119 def GetEvtHandlerEnabled(self
):
120 """Return True if the event handler is enabled, False
124 def GetNextHandler(self
):
125 """Return the next handler in the chain."""
128 def GetPreviousHandler(self
):
129 """Return the previous handler in the chain."""
132 def ProcessEvent(self
, event
):
133 """Processes an event, searching event tables and calling zero
134 or more suitable event handler function(s). Return True if a
135 suitable event handler function was found and executed, and
136 the function did not call Event.Skip().
138 event is an Event to process.
140 Normally, your application would not call this function: it is
141 called in the wxPython implementation to dispatch incoming
142 user interface events to the framework (and application).
144 However, you might need to call it if implementing new
145 functionality (such as a new control) where you define new
146 event types, as opposed to allowing the user to override
149 An instance where you might actually override the ProcessEvent
150 function is where you want to direct event processing to event
151 handlers not normally noticed by wxWindows. For example, in
152 the document/view architecture, documents and views are
153 potential event handlers. When an event reaches a frame,
154 ProcessEvent will need to be called on the associated document
155 and view in case event handler functions are associated with
156 these objects. The property classes library (Property) also
157 overrides ProcessEvent for similar reasons.
159 The normal order of event table searching is as follows:
161 1. If the object is disabled (via a call to
162 EvtHandler.SetEvtHandlerEnabled) the function skips to step
165 2. If the object is a Window, ProcessEvent is recursively
166 called on the window's Validator. If this returns TRUE, the
169 3. SearchEventTable is called for this event handler. If this
170 fails, the base class table is tried, and so on until no more
171 tables exist or an appropriate function was found, in which
172 case the function exits.
174 4. The search is applied down the entire chain of event
175 handlers (usually the chain has a length of one). If this
176 succeeds, the function exits.
178 5. If the object is a Window and the event is a
179 CommandEvent, ProcessEvent is recursively applied to the
180 parent window's event handler. If this returns TRUE, the
183 6. Finally, ProcessEvent is called on the App object.
187 EvtHandler::SearchEventTable"""
190 def SetEvtHandlerEnabled(self
, enabled
):
191 """Enable or disable the event handler.
193 You can use this function to avoid having to remove the event
194 handler from the chain, for example when implementing a dialog
195 editor and changing from edit to test mode."""
198 def SetNextHandler(self
, handler
):
199 """Set the pointer to the next handler."""
202 def SetPreviousHandler(self
, handler
):
203 """Set the pointer to the previous handler."""