Skip to content

Discussion: adding event watchers #3648

@SuperRedingBros

Description

@SuperRedingBros

Description

Basically, the goal is to add event watchers as a new potential way of handling events, to complement the standard event loop without breaking compatibility.

Currently, the syntax is like this:

@pygame.event.add_event_watcher
def eventWatcher(event):
    ... # use the event somehow

Whenever events are added to the queue, they are sent to the event watchers, they can still be accessed from an event loop as usual, however.
@ankith26 and @aatle proposed making them behave more like SDL_appEvent, however, IMO that is somewhat more intrusive to the standard event loop. I am curious what other people think about it.

Currently, any exceptions thrown by the watcher are logged and otherwise ignored, this is probably not great. Again, I am interested in other people's input on the matter

I already have opened a PR for this, #3637; there are some other details and an example usage of the feature there as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions