Repository navigation
Add a Windows and Views page to the programming guide - #2973
Merged
Merged
Conversation
Explains the window, when to use views, what show_view does, why on_show_view runs every time a view is shown, how events reach a view and then the window, resizing while hidden, per-view background colors, and UIView. Fixes Window.show_view's docstring, which said the new view is shown in the next frame; it calls on_hide_view and on_show_view before returning. on_show_view's docstring said it's called once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2549
Adds Windows and Views to the programming guide (Manual section, before Event Loop). It covers:
if self.state == ...in every method, with a menu → game example.show_view()does, in order.__init__runs once, buton_show_viewruns every time the view is shown, so the page says what belongs in each. There's a pause-screen example that shows the same game view again, so the game continues.True. The trap is aWindowsubclass whoseon_drawdraws on top of every view. pushfoo mentioned confusion about theon_methods in the issue.on_resize, so update cameras inon_show_view.UIView: it enables and disables itsUIManageron show and hide, and overrides must callsuper().I checked the behavior described by running views in a hidden window: the order of calls, events reaching the view and then the window, returning
Truestopping the window's handler, andon_show_viewrunning again when a view is reshown. I also ran the page's examples.Docstring fixes
Window.show_view()said it shows the new view "in the next frame" and is "not a blocking call". It actually callson_hide_view()on the old view andon_show_view()on the new one before returning. The docstring now says that and links to the new page.View.on_show_view()said "Called once when the view is shown". It runs each time the view is shown. The docstring now says what belongs there versus__init__.View.on_hide_view()now says when it's called and what it's for.Viewport and scissor, mentioned in the issue, fit better in the camera guide, so they're not on this page.
The docs build with
-W(nitpicky) passes, and ruff passes.🤖 Generated with Claude Code