Skip to content

Major improvements to pygame.event introduction documentation - #3738

Merged
Starbuck5 merged 4 commits into
pygame-community:mainfrom
damusss:improve-event-docs
Apr 12, 2026
Merged

Starbuck5 merged 4 commits into
pygame-community:mainfrom
damusss:improve-event-docs

Conversation

@damusss

@damusss damusss commented Mar 11, 2026 •

Copy link
Copy Markdown
Member

The current version is one of the most confusing documentations I've ever read. This PR properly organizes the information in a readable and concise manner. Main issues:

  • Some incorrect/useless/missing information
  • Too many multiple lists for no reason with visually disconnected events of the same category
  • Random descriptions scattered around that can be more concise and added next to the event type
  • Randomly scattered and duplicate version changed/added tags

The current version uses a "history" approach, as if it was narrating how events changed over time, which is not useful for someone learning how to handle events. I've slightly edited and separated with headers the text walls and organized the event types in 3 lists (the first one separates events by category). I only added descriptions for the events that really needed them, connecting them to the respecting types/attributes. The documentation about TEXT* events is completely new. I genuinely had no idea what those events were, and I honestly don't expect most people to know, therefore I think the notes are useful.

Detailed breakdown of decisions:

  • Strictly requiring the display module is outdated, as either the display or window API will make events work properly.
  • The fact that not handling events will cause a not responding status is important enough to be highlighted.
  • The window attribute of non-window events was never documented.
  • It's redundant to say "when compiled with SDL2" and then add a new list. pygame-ce is always compiled with SDL2, and those events can be paired with their peers.
  • versionaddedold:: 1.9.5 doesn't specify anything (intuitively the new SDL2 events, but unless they are all listed, this tag can go)
  • versionchangedold:: 2.0.2: a non-major bugfix shouldn't get its own versionchanged tag
  • "Many new events were introduced in pygame 2" is not a useful history lesson
  • DROP*/MIDI*/KEYMAPCHANGED/CLIPBOARDUPDATE event descriptions can be made concise next to the event type
  • "pygame 2 also supports controller hot-plugging" can be seen from the existence of the plugging events, the history lesson is redundant
  • "Also in this version, instance_id..." versionchanged tags exist to replace this
  • "LOCALECHANGED is an event sent when user locale changes" is like saying the QUIT event is sent when the app quits
  • WINDOWRESIZED/WINDOWSIZECHANGED ambiguity was important to clarify
  • window events having the window attribute should not be mentioned casually in a later description, and there's no need to specify attributes on a description when each event type is already described.

@damusss
damusss requested a review from a team as a code owner March 11, 2026 23:05
@damusss damusss added docs event pygame.event labels Mar 11, 2026
@coderabbitai

coderabbitai Bot commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a7bbf5db-6439-4687-9a4a-34d089e68002

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 500b31a and f3a3863.

πŸ“’ Files selected for processing (1)
  • docs/reST/ref/event.rst
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/reST/ref/event.rst

πŸ“ Walkthrough

Walkthrough

Rewrites and restructures the event reference: clarifies the event queue dependency on the video/window system and per-frame processing, makes event objects attribute-centric, adds per-event attribute tables, modernizes window/controller/IME/file-drop/Android events, and consolidates versioning notes. (50 words)

Changes

Cohort / File(s) Summary
Event documentation
docs/reST/ref/event.rst
Complete rewrite of the event reference: new "Event queue" guidance (dependence on video/window system; process events each frame; set_allowed/set_blocked), explicit note that input-state access still requires the internal event queue to run, attribute-centric "Event objects" description, per-event attribute table, added/updated events (DROP*, TEXTINPUT/TEXTEDITING/IME, controller hot-plug, SDL/system audio/render reset, file/text drop), modernized window events with window/display attributes and display_index, legacy events marked as legacy, and updated Android/event versioning notes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ankith26
πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Title check βœ… Passed The title directly and accurately summarizes the main changeβ€”major improvements to pygame.event introduction documentation.
Description check βœ… Passed The description is highly relevant, detailing specific issues with the current documentation and explaining the restructuring decisions made in this PR.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/reST/ref/event.rst`:
- Line 224: Fix the spelling in the versionadded directive: replace the
misspelled word "Adroid" with "Android" in the line beginning with "..
versionadded:: 2.1.3" (the text containing "Adroid events, ``precise_x`` and
``precise_y`` to ``MOUSEWHEEL`` events") so the directive reads "..
versionadded:: 2.1.3 Android events, ``precise_x`` and ``precise_y`` to
``MOUSEWHEEL`` events".
- Line 60: Correct the spelling of "instantianting" to "instantiating" in the
documentation sentence that references the Event constructor (the phrase
containing ":func:`pygame.event.Event()`"); update that occurrence so the
sentence reads "instantiating :func:`pygame.event.Event()` themselves, usually
paired" (or equivalent grammatical adjustment) to fix the typo.
- Around line 94-133: Update the event attribute listings to indicate the
presence of a window attribute for events whose implementation sets it: include
"window" in the attribute list (or add a parenthetical note) for KEYDOWN, KEYUP,
MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN, MOUSEWHEEL, TEXTEDITING, TEXTINPUT,
DROPFILE, DROPBEGIN, DROPCOMPLETE, DROPTEXT, FINGERMOTION, FINGERDOWN, and
FINGERUP so the docs explicitly state the window that received the event.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b6520271-3286-47bf-8dfd-c7fb4b72833d

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between bda4eae and a59b342.

πŸ“’ Files selected for processing (1)
  • docs/reST/ref/event.rst

Comment thread docs/reST/ref/event.rst Resolved
Comment thread docs/reST/ref/event.rst Resolved
Comment thread docs/reST/ref/event.rst Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/reST/ref/event.rst`:
- Around line 187-190: Remove the incorrect "(x, y attributes)" annotation from
the WINDOWMOVED and WINDOWRESIZED entries so only WINDOWSIZECHANGED retains the
"(x, y attributes)" note; update the event list block that contains WINDOWMOVED,
WINDOWSIZECHANGED, and WINDOWRESIZED to match the source comment in
src_c/event.c (only WINDOWSIZECHANGED should show x,y attributes).
- Line 92: The docs line listing a `code` attribute for USEREVENT is misleading;
update the USEREVENT entry to either remove the `code` mention or reword it to
state that USEREVENT has no standard system attributes and that users may attach
arbitrary attributes as needed (referencing the USEREVENT symbol and the `code`
attribute in the entry so the maintainer knows which token to change).

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4846e5c9-0093-4f9c-914e-813cc7d1aa28

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a59b342 and 374387a.

πŸ“’ Files selected for processing (1)
  • docs/reST/ref/event.rst

Comment thread docs/reST/ref/event.rst Resolved
Comment thread docs/reST/ref/event.rst Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docs/reST/ref/event.rst (1)

92-93: ⚠️ Potential issue | 🟑 Minor

Clarify that USEREVENT has no standard attributes.

Removing the legacy code implication helps, but this row still reads like a normal system-event entry. I’d explicitly say that USEREVENT is just the first value in the user-defined range and has no guaranteed attributes, so readers do not infer an omitted default attribute set from the table.

πŸ“ Suggested wording
-    USEREVENT                  (Starting type of the user defined
-                                event types)
+    USEREVENT                  (No guaranteed attributes; starting value
+                                of the user-defined event type range,
+                                ``USEREVENT`` to ``NUMEVENTS - 1``)

Based on learnings, "USEREVENT has no guaranteed system attributes. It is only the starting value of the user-defined event type range (USEREVENT to NUMEVENTS-1). The code attribute listed in older documentation was erroneous/legacy and does not apply."

πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/reST/ref/event.rst` around lines 92 - 93, Update the table row for
USEREVENT to explicitly state it has no guaranteed system attributes and is only
the starting value of the user-defined event range; mention the range (USEREVENT
to NUMEVENTS-1) and that the older implication of a `code` attribute was
legacy/erroneous and does not apply, so readers won't infer any default
attribute set for USEREVENT.
πŸ€– Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/reST/ref/event.rst`:
- Around line 92-93: Update the table row for USEREVENT to explicitly state it
has no guaranteed system attributes and is only the starting value of the
user-defined event range; mention the range (USEREVENT to NUMEVENTS-1) and that
the older implication of a `code` attribute was legacy/erroneous and does not
apply, so readers won't infer any default attribute set for USEREVENT.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 62da0181-3de9-43a8-b366-3ecd5713f20a

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 374387a and 500b31a.

πŸ“’ Files selected for processing (1)
  • docs/reST/ref/event.rst

routines -> functions, clearer
"If it has not been initialized" - what is "it"?
"and process them" unnecessary and not good grammar in context
We wouldn't recommend filtering, so why does it need a paragraph?
Clarify bit about events still needing to be pumped
Events are not in "stack", they are on a queue.
__dict__ is irrelevant
Simplify wording of custom_type() bit.
Why does event_name need a sentence to be hyped?
DROPTEXT works on Windows, tested.
@Starbuck5

Copy link
Copy Markdown
Member

@damusss I love stuff like this. I had a couple extra improvements on a read through, but rather than telling you them I just made my own commit. Please take a look.

Change descriptions, in order, very concise:
routines -> functions, clearer
"If it has not been initialized" - what is "it"?
"and process them" unnecessary and not good grammar in context
We wouldn't recommend filtering, so why does it need a paragraph?
Clarify bit about events still needing to be pumped
Events are not in "stack", they are on a queue.
__dict__ is irrelevant
Simplify wording of custom_type() bit.
Why does event_name need a sentence to be hyped?
DROPTEXT works on Windows, tested.

@damusss

damusss commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@Starbuck5 thank you for the commit! The introductory part needed an extra improvement.

@ankith26 ankith26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks πŸŽ‰

@Starbuck5
Starbuck5 merged commit df61d67 into pygame-community:main Apr 12, 2026
21 checks passed
@Starbuck5 Starbuck5 added this to the 2.5.8 milestone Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs event pygame.event

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants