peng3d/peng.py
def sendPygletEvent(self,event_type,args,window=None):
        """
        Handles a pyglet event.
        
        This method is called by :py:meth:`PengWindow.dispatch_event()` and handles all events.
        
        See :py:meth:`registerEventHandler()` for how to listen to these events.
        
        This method should be used to send pyglet events.
        For new code, it is recommended to use :py:meth:`sendEvent()` instead.
        For "tunneling" pyglet events, use event names of the format ``pyglet:<event>``
        and for the data use ``{"args":<args as list>,"window":<window object or none>,"src":<event source>,"event_type":<event type>}``
        
        Note that you should send pyglet events only via this method, the above event will be sent automatically.
        
        Do not use this method to send custom events, use :py:meth:`sendEvent` instead.
        """
        args = list(args)
        
        self.sendEvent("pyglet:%s"%event_type,{"peng":self,"args":args,"window":window,"src":self,"event_type":event_type})
        self.sendEvent("peng3d:pyglet",{"peng":self,"args":args,"window":window,"src":self,"event_type":event_type})
        
        if event_type not in ["on_draw","on_mouse_motion"] and self.cfg["debug.events.dump"]:
            print("Event %s with args %s"%(event_type,args))
        if event_type in self.pygletEventHandlers:
            for whandler in self.pygletEventHandlers[event_type]:
                # This allows for proper collection of deleted handler methods by using weak references
                handler = whandler()
                if handler is None:
                    del self.pygletEventHandlers[event_type][self.pygletEventHandlers[event_type].index(whandler)]
                handler(*args)
def sendPygletEvent(self,event_type,args,window=None):
        """
        Handles a pyglet event.
        
        This method is called by :py:meth:`PengWindow.dispatch_event()` and handles all events.
        
        See :py:meth:`registerEventHandler()` for how to listen to these events.
        
        This method should be used to send pyglet events.
        For new code, it is recommended to use :py:meth:`sendEvent()` instead.
        For "tunneling" pyglet events, use event names of the format ``pyglet:<event>``
        and for the data use ``{"args":<args as list>,"window":<window object or none>,"src":<event source>,"event_type":<event type>}``
        
        Note that you should send pyglet events only via this method, the above event will be sent automatically.
        
        Do not use this method to send custom events, use :py:meth:`sendEvent` instead.
        """
        args = list(args)
        
        self.sendEvent("pyglet:%s"%event_type,{"peng":self,"args":args,"window":window,"src":self,"event_type":event_type})
        self.sendEvent("peng3d:pyglet",{"peng":self,"args":args,"window":window,"src":self,"event_type":event_type})
        
        if event_type not in ["on_draw","on_mouse_motion"] and self.cfg["debug.events.dump"]:
            print("Event %s with args %s"%(event_type,args))
        if event_type in self.pygletEventHandlers:
            for whandler in self.pygletEventHandlers[event_type]:
                # This allows for proper collection of deleted handler methods by using weak references
                handler = whandler()
                if handler is None:
                    del self.pygletEventHandlers[event_type][self.pygletEventHandlers[event_type].index(whandler)]
                handler(*args)
Handles a pyglet event.
        
        This method is called by :py:meth:`PengWindow.dispatch_event()` and handles all events.
        
        See :py:meth:`registerEventHandler()` for how to listen to these events.
        
        This method should be used to send pyglet events.
        For new code, it is recommended to use :py:meth:`sendEvent()` instead.
        For "tunneling" pyglet events, use event names of the format ``pyglet:<event>``
        and for the data use ``{"args":<args as list>,"window":<window object or none>,"src":<event source>,"event_type":<event type>}``
        
        Note that you should send pyglet events only via this method, the above event will be sent automatically.
        
        Do not use this method to send custom events, use :py:meth:`sendEvent` instead.