[Tkinter-discuss] Convert Tk command string to Python callback

Michael Lange klappnase at web.de
Mon Nov 14 21:59:54 CET 2005


Hello everyone,

I need to to pass attributes of an event (or maybe the event instance as a whole) to
another callback.
A pseudo-code function to illustrate what I want to achieve:

    def deliver_event(self, event):
        binding = self.tag_bind(tagOrId, '<sequence>')
        if binding:
            binding(event)

Of course this won't work because "binding" is a string that looks like:

    if {"[-1215579924drag_leave_canv %A %a %b %C %c %D %d %m %T %t %W %X %x %Y %y]" == "break"} break

I just wondered if there is a way to replace the percent substitutions with the attributes of the event
or (even better) to access the associated python callback from the tk command string.

Any pointers are much appreciated.

Thanks in advance

Michael



More information about the Tkinter-discuss mailing list