def get_children_recursively( parent: tkinter.Misc, *, include_parent: bool = False ) -> Iterator[tkinter.Misc]: if include_parent: yield parent for child in parent.winfo_children(): yield from get_children_recursively(child, include_parent=True)
def _bind_tree(self, widget: tk.Misc, event: str, callback: callable, add: str = "") -> None: """Binds an event to a widget and all its descendants recursively. Parameters ---------- widget : tk.Misc The widget to bind the callback to. event : str The event to bind to the widget. callback : callable The callback to call on event. add : str, default "" Specifies whether callback will be called additionally ("+") to the other bound function or whether it will replace the previous function (""). """ widget.bind(event, callback, add) for child in widget.winfo_children(): self._bind_tree(child, event, callback, add)