(widget)
return MultiCall
Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
Return a MultiCall class which inherits its methods from the given widget class ( for example Tkinter . Text ) . This is used instead of a templating mechanism .
def MultiCallCreator(widget):
    """Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
    """
    if widget in _multicall_dict:
        return _multicall_dict[widget]

    class MultiCall (widget):
        assert issubclass(widget, tkinter.Misc)

        def __init__(self, *args, **kwargs):
            widget.__init__(self, *args, **kwargs)
            # a dictionary which maps a virtual event to a tuple with:
            #  0. the function binded
            #  1. a list of triplets - the sequences it is binded to
            self.__eventinfo = {}
            self.__binders = [_binder_classes[i](i, widget, self)
                              for i in range(len(_types))]

        def bind(self, sequence=None, func=None, add=None):
            #print("bind(%s, %s, %s)" % (sequence, func, add),
            #      file=sys.__stderr__)
            if type(sequence) is str and len(sequence) > 2 and \
               sequence[:2] == "<<" and sequence[-2:] == ">>":
                if sequence in self.__eventinfo:
                    ei = self.__eventinfo[sequence]
                    if ei[0] is not None:
                        for triplet in ei[1]:
                            self.__binders[triplet[1]].unbind(triplet, ei[0])
                    ei[0] = func
                    if ei[0] is not None:
                        for triplet in ei[1]:
                            self.__binders[triplet[1]].bind(triplet, func)
                else:
                    self.__eventinfo[sequence] = [func, []]
            return widget.bind(self, sequence, func, add)

        def unbind(self, sequence, funcid=None):
            if type(sequence) is str and len(sequence) > 2 and \
               sequence[:2] == "<<" and sequence[-2:] == ">>" and \
               sequence in self.__eventinfo:
                func, triplets = self.__eventinfo[sequence]
                if func is not None:
                    for triplet in triplets:
                        self.__binders[triplet[1]].unbind(triplet, func)
                    self.__eventinfo[sequence][0] = None
            return widget.unbind(self, sequence, funcid)

        def event_add(self, virtual, *sequences):
            #print("event_add(%s, %s)" % (repr(virtual), repr(sequences)),
            #      file=sys.__stderr__)
            if virtual not in self.__eventinfo:
                self.__eventinfo[virtual] = [None, []]

            func, triplets = self.__eventinfo[virtual]
            for seq in sequences:
                triplet = _parse_sequence(seq)
                if triplet is None:
                    #print("Tkinter event_add(%s)" % seq, file=sys.__stderr__)
                    widget.event_add(self, virtual, seq)
                else:
                    if func is not None:
                        self.__binders[triplet[1]].bind(triplet, func)
                    triplets.append(triplet)

        def event_delete(self, virtual, *sequences):
            if virtual not in self.__eventinfo:
                return
            func, triplets = self.__eventinfo[virtual]
            for seq in sequences:
                triplet = _parse_sequence(seq)
                if triplet is None:
                    #print("Tkinter event_delete: %s" % seq, file=sys.__stderr__)
                    widget.event_delete(self, virtual, seq)
                else:
                    if func is not None:
                        self.__binders[triplet[1]].unbind(triplet, func)
                    triplets.remove(triplet)

        def event_info(self, virtual=None):
            if virtual is None or virtual not in self.__eventinfo:
                return widget.event_info(self, virtual)
            else:
                return tuple(map(_triplet_to_sequence,
                                 self.__eventinfo[virtual][1])) + \
                       widget.event_info(self, virtual)

        def __del__(self):
            for virtual in self.__eventinfo:
                func, triplets = self.__eventinfo[virtual]
                if func:
                    for triplet in triplets:
                        try:
                            self.__binders[triplet[1]].unbind(triplet, func)
                        except tkinter.TclError as e:
                            if not APPLICATION_GONE in e.args[0]:
                                raise

    _multicall_dict[widget] = MultiCall
    return MultiCall
def MultiCallCreator ( widget ) : if widget in _multicall_dict : return _multicall_dict [ widget ] class MultiCall ( widget ) : assert issubclass ( widget , tkinter . Misc ) def __init__ ( self , * args , * * kwargs ) : widget . __init__ ( self , * args , * * kwargs ) # a dictionary which maps a virtual event to a tuple with: #  0. the function binded #  1. a list of triplets - the sequences it is binded to self . __eventinfo = { } self . __binders = [ _binder_classes [ i ] ( i , widget , self ) for i in range ( len ( _types ) ) ] def bind ( self , sequence = None , func = None , add = None ) : #print("bind(%s, %s, %s)" % (sequence, func, add), #      file=sys.__stderr__) if type ( sequence ) is str and len ( sequence ) > 2 and sequence [ : 2 ] == "<<" and sequence [ - 2 : ] == ">>" : if sequence in self . __eventinfo : ei = self . __eventinfo [ sequence ] if ei [ 0 ] is not None : for triplet in ei [ 1 ] : self . __binders [ triplet [ 1 ] ] . unbind ( triplet , ei [ 0 ] ) ei [ 0 ] = func if ei [ 0 ] is not None : for triplet in ei [ 1 ] : self . __binders [ triplet [ 1 ] ] . bind ( triplet , func ) else : self . __eventinfo [ sequence ] = [ func , [ ] ] return widget . bind ( self , sequence , func , add ) def unbind ( self , sequence , funcid = None ) : if type ( sequence ) is str and len ( sequence ) > 2 and sequence [ : 2 ] == "<<" and sequence [ - 2 : ] == ">>" and sequence in self . __eventinfo : func , triplets = self . __eventinfo [ sequence ] if func is not None : for triplet in triplets : self . __binders [ triplet [ 1 ] ] . unbind ( triplet , func ) self . __eventinfo [ sequence ] [ 0 ] = None return widget . unbind ( self , sequence , funcid ) def event_add ( self , virtual , * sequences ) : #print("event_add(%s, %s)" % (repr(virtual), repr(sequences)), #      file=sys.__stderr__) if virtual not in self . __eventinfo : self . __eventinfo [ virtual ] = [ None , [ ] ] func , triplets = self . __eventinfo [ virtual ] for seq in sequences : triplet = _parse_sequence ( seq ) if triplet is None : #print("Tkinter event_add(%s)" % seq, file=sys.__stderr__) widget . event_add ( self , virtual , seq ) else : if func is not None : self . __binders [ triplet [ 1 ] ] . bind ( triplet , func ) triplets . append ( triplet ) def event_delete ( self , virtual , * sequences ) : if virtual not in self . __eventinfo : return func , triplets = self . __eventinfo [ virtual ] for seq in sequences : triplet = _parse_sequence ( seq ) if triplet is None : #print("Tkinter event_delete: %s" % seq, file=sys.__stderr__) widget . event_delete ( self , virtual , seq ) else : if func is not None : self . __binders [ triplet [ 1 ] ] . unbind ( triplet , func ) triplets . remove ( triplet ) def event_info ( self , virtual = None ) : if virtual is None or virtual not in self . __eventinfo : return widget . event_info ( self , virtual ) else : return tuple ( map ( _triplet_to_sequence , self . __eventinfo [ virtual ] [ 1 ] ) ) + widget . event_info ( self , virtual ) def __del__ ( self ) : for virtual in self . __eventinfo : func , triplets = self . __eventinfo [ virtual ] if func : for triplet in triplets : try : self . __binders [ triplet [ 1 ] ] . unbind ( triplet , func ) except tkinter . TclError as e : if not APPLICATION_GONE in e . args [ 0 ] : raise _multicall_dict [ widget ] = MultiCall return MultiCall