turbosnake/ttk/_utils.py
def tk_with_events(event_map: Iterable[str, str]):
    """Decorator for tk-component that invokes event handlers from it's props when tk's events happen.

    @tk_with_events({
        '<<Button-1>>': 'on_mouse_down',
    })
    class MyComponent(TkComponent):
        ...

    :param event_map iterable of pairs (event sequence - handler property name)
    """

    def _tk_component_with_events(component):
        original_create_widget = component.create_widget

        assert issubclass(component, TkComponent)

        def create_widget(self, *args, **kwargs):
            widget: tk.Widget = original_create_widget(self, *args, **kwargs)

            for (event_sequence, prop_name) in event_map:
                widget.bind(event_sequence, event_prop_invoker(self, prop_name))

            return widget

        component.create_widget = create_widget

        return component

    return _tk_component_with_events
Decorator for tk-component that invokes event handlers from it's props when tk's events happen.

    @tk_with_events({
        '<<Button-1>>': 'on_mouse_down',
    })
    class MyComponent(TkComponent):
        ...

    :param event_map iterable of pairs (event sequence - handler property name)
    
Decorator for tk-component that invokes event handlers from it's props when tk's events happen.

:param event_map iterable of pairs (event sequence - handler property name)
Decorator for tk - component that invokes event handlers from it ' s props when tk ' s events happen . : param event_map iterable of pairs ( event sequence - handler property name )
def tk_with_events(event_map: Iterable[str, str]):
    def _tk_component_with_events(component):
        original_create_widget = component.create_widget
        assert issubclass(component, TkComponent)
        def create_widget(self, *args, **kwargs):
            widget: tk.Widget = original_create_widget(self, *args, **kwargs)
            for (event_sequence, prop_name) in event_map:
                widget.bind(event_sequence, event_prop_invoker(self, prop_name))
            return widget
        component.create_widget = create_widget
        return component
    return _tk_component_with_events
def tk_with_events ( event_map : Iterable [ str , str ] ) : def _tk_component_with_events ( component ) : original_create_widget = component . create_widget assert issubclass ( component , TkComponent ) def create_widget ( self , * args , ** kwargs ) : widget : tk . Widget = original_create_widget ( self , * args , ** kwargs ) for ( event_sequence , prop_name ) in event_map : widget . bind ( event_sequence , event_prop_invoker ( self , prop_name ) ) return widget component . create_widget = create_widget return component return _tk_component_with_events
Decorator for tk-component that invokes event handlers from it's props when tk's events happen.
Decorator for tk - component that invokes event handlers from it ' s props when tk ' s events happen .
"""Decorator for tk-component that invokes event handlers from it's props when tk's events happen.

    @tk_with_events({
        '<<Button-1>>': 'on_mouse_down',
    })
    class MyComponent(TkComponent):
        ...

    :param event_map iterable of pairs (event sequence - handler property name)
    """
event_map
Iterable[str, str]