comparison engine/extensions/pychan/widgets.py @ 164:5b04a7d3ded6

typo fix some missing event (de)registrations ability to capture one event multiple times (instead of only having one slot, we have groups and each group has an own slot, the default group is "default" so we are backward compatible
author spq@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 15 Oct 2008 14:57:04 +0000
parents c305c5eda7ed
children 81a222e7bd25
comparison
equal deleted inserted replaced
163:31718fa356f8 164:5b04a7d3ded6
164 for k,v in kwargs.items(): 164 for k,v in kwargs.items():
165 if v != getattr(self,k,None): 165 if v != getattr(self,k,None):
166 return False 166 return False
167 return True 167 return True
168 168
169 def capture(self, callback, event_name="action"): 169 def capture(self, callback, event_name="action", group_name="default"):
170 """ 170 """
171 Add a callback to be executed when the widget event occurs on this widget. 171 Add a callback to be executed when the widget event occurs on this widget.
172 172
173 The callback must be either a callable or None. 173 The callback must be either a callable or None.
174 The old event handler (if any) will be overridden by the callback. 174 The old event handler (if any) will be overridden by the callback.
178 It might be useful to check out L{tools.callbackWithArguments}. 178 It might be useful to check out L{tools.callbackWithArguments}.
179 179
180 @param callback: Event callback - may accept keyword arguments event and widget. 180 @param callback: Event callback - may accept keyword arguments event and widget.
181 @paran event_name: The event to capture - may be one of L{events.EVENTS} and defaults to "action" 181 @paran event_name: The event to capture - may be one of L{events.EVENTS} and defaults to "action"
182 """ 182 """
183 self.event_mapper.capture( event_name, callback ) 183 self.event_mapper.capture( event_name, callback, group_name )
184 184
185 def isCaptured(self): 185 def isCaptured(self):
186 """ 186 """
187 Check whether this widgets events are captured 187 Check whether this widgets events are captured
188 (a callback is installed) or not. 188 (a callback is installed) or not.
338 "button/mouseExited" : toggleButtonColorBlue, 338 "button/mouseExited" : toggleButtonColorBlue,
339 }) 339 })
340 340
341 """ 341 """
342 for descr,func in eventMap.items(): 342 for descr,func in eventMap.items():
343 name, event_name = events.splitEventDescriptor(descr) 343 name, event_name, group_name = events.splitEventDescriptor(descr)
344 print name, event_name 344 print name, event_name, group_name
345 widget = self.findChild(name=name) 345 widget = self.findChild(name=name)
346 if widget: 346 if widget:
347 widget.capture( func, event_name = event_name ) 347 widget.capture( func, event_name = event_name, group_name = group_name )
348 elif not ignoreMissing: 348 elif not ignoreMissing:
349 raise RuntimeError("No widget with the name: %s" % name) 349 raise RuntimeError("No widget with the name: %s" % name)
350 350
351 def setInitialData(self,data): 351 def setInitialData(self,data):
352 """ 352 """