# HG changeset patch # User phoku@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1237883074 0 # Node ID e476b6b7b2f00bfb2192f30f1c6ac6b61100493c # Parent 4a5e8e638b0db0462598df43f952617a01fa22e9 Added removeAllChildren method. (untested) Documentation on event groups. diff -r 4a5e8e638b0d -r e476b6b7b2f0 engine/extensions/pychan/widgets.py --- a/engine/extensions/pychan/widgets.py Tue Mar 24 08:09:57 2009 +0000 +++ b/engine/extensions/pychan/widgets.py Tue Mar 24 08:24:34 2009 +0000 @@ -196,6 +196,11 @@ @param callback: Event callback - may accept keyword arguments event and widget. @paran event_name: The event to capture - may be one of L{events.EVENTS} and defaults to "action" + @paran group_name: Event group. + + Event groups are used to have different B{channels} which don't interfere with each other. + For derived widgets that need to capture events it's advised to use the group_name 'widget'. + The 'default' group is used by default, and should be reserved for the application programmers. """ self.event_mapper.capture( event_name, callback, group_name ) @@ -289,6 +294,7 @@ Usage:: closeButtons = root_widget.findChildren(name='close') + buttons = root_widget.findChildren(__class__=pychan.widgets.Button) """ children = [] @@ -331,6 +337,15 @@ for widget in widgets: self.removeChild(widget) + def removeAllChildren(self): + """ + This function will remove all direct child widgets. + This will work even for non-container widgets. + """ + children = self.findChildren(parent=self) + for widget in children: + self.removeChild(widget) + def mapEvents(self,eventMap,ignoreMissing = False): """ Convenience function to map widget events to functions