peng3d/peng.py
def addPygletListener(self,event_type,handler):
        """
        Registers an event handler.
        
        The specified callable handler will be called every time an event with the same ``event_type`` is encountered.
        
        All event arguments are passed as positional arguments.
        
        This method should be used to listen for pyglet events.
        For new code, it is recommended to use :py:meth:`addEventListener()` instead.
        
        See :py:meth:`handleEvent()` for information about tunneled pyglet events.
        
        For custom events, use :py:meth:`addEventListener()` instead.
        """
        if self.cfg["debug.events.register"]:
            print("Registered Event: %s Handler: %s"%(event_type,handler))
        if event_type not in self.pygletEventHandlers:
            self.pygletEventHandlers[event_type]=[]
        # Only a weak reference is kept
        if inspect.ismethod(handler):
            handler = weakref.WeakMethod(handler)
        else:
            handler = weakref.ref(handler)
        self.pygletEventHandlers[event_type].append(handler)
def addPygletListener(self,event_type,handler):
        """
        Registers an event handler.
        
        The specified callable handler will be called every time an event with the same ``event_type`` is encountered.
        
        All event arguments are passed as positional arguments.
        
        This method should be used to listen for pyglet events.
        For new code, it is recommended to use :py:meth:`addEventListener()` instead.
        
        See :py:meth:`handleEvent()` for information about tunneled pyglet events.
        
        For custom events, use :py:meth:`addEventListener()` instead.
        """
        if self.cfg["debug.events.register"]:
            print("Registered Event: %s Handler: %s"%(event_type,handler))
        if event_type not in self.pygletEventHandlers:
            self.pygletEventHandlers[event_type]=[]
        # Only a weak reference is kept
        if inspect.ismethod(handler):
            handler = weakref.WeakMethod(handler)
        else:
            handler = weakref.ref(handler)
        self.pygletEventHandlers[event_type].append(handler)
def addPygletListener ( self , event_type , handler ) : if self . cfg [ "debug.events.register" ] : print ( "Registered Event: %s Handler: %s" % ( event_type , handler ) ) if event_type not in self . pygletEventHandlers : self . pygletEventHandlers [ event_type ] = [ ] # Only a weak reference is kept if inspect . ismethod ( handler ) : handler = weakref . WeakMethod ( handler ) else : handler = weakref . ref ( handler ) self . pygletEventHandlers [ event_type ] . append ( handler )
Registers an event handler.
        
        The specified callable handler will be called every time an event with the same ``event_type`` is encountered.
        
        All event arguments are passed as positional arguments.
        
        This method should be used to listen for pyglet events.
        For new code, it is recommended to use :py:meth:`addEventListener()` instead.
        
        See :py:meth:`handleEvent()` for information about tunneled pyglet events.
        
        For custom events, use :py:meth:`addEventListener()` instead.
Registers an event handler . The specified callable handler will be called every time an event with the same event_type is encountered . All event arguments are passed as positional arguments . This method should be used to listen for pyglet events . For new code it is recommended to use : py : meth : addEventListener () instead . See : py : meth : handleEvent () for information about tunneled pyglet events . For custom events use : py : meth : addEventListener () instead .