Add RenderWindow class for Pygame window management - #10
Add RenderWindow class for Pygame window management#10dmccoystephenson with Copilot wants to merge 6 commits into
Conversation
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
RenderWindow class to manage Pygame initialization
dmccoystephenson
left a comment
There was a problem hiding this comment.
@copilot The new class does not appear to be used anywhere
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Added usage examples in |
Introduces this repo's first tests/ directory. Covers init, tick, event dispatch, and QUIT handling for the RenderWindow class added in this PR, without opening a real display. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Self-review rubric (dev-loop adoption of this draft PR):
No functional changes were made to the copilot-authored implementation — I rebased onto current One blocker for merge: this PR is still marked Draft. |
|
A status update is provided on the two outstanding blockers for this PR. The The PR also remains marked as a Draft. No code changes were made in this pass; prior test coverage and self-review (see above) are believed to still hold, since no new commits landed on this PR since they were posted. This PR comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
There was a problem hiding this comment.
Pull request overview
This pull request introduces a new RenderWindow utility to centralize Pygame initialization, window/surface management, event processing, and frame-rate control, with supporting documentation and examples to encourage composition-based usage across the codebase (and downstream projects like Apex).
Changes:
- Added
RenderWindowimplementation with an event-handler registration API and internal QUIT handling. - Added unit tests validating window setup, tick delegation, and event dispatch behavior.
- Added documentation and an examples script demonstrating basic usage and integration patterns.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
render_window.py |
Implements the new RenderWindow class and its event loop/handler dispatch. |
tests/test_render_window.py |
Adds unit tests for initialization, ticking, and event/QUIT behavior. |
render_window_example.py |
Provides runnable examples showing basic usage, handler registration, and integration with Graphik. |
README.md |
Documents RenderWindow features and basic usage. |
.gitignore |
Ignores __pycache__/ directories. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| self.assertFalse(result) | ||
|
|
||
| def test_register_event_handler_not_called_for_quit(self): |
| for event in pygame.event.get(): | ||
| if event.type == pygame.QUIT: | ||
| self._running = False | ||
| else: | ||
| # Call all registered event handlers | ||
| for handler in self._event_handlers: | ||
| handler(event) | ||
|
|
||
| return self._running |
Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Overview
This PR adds a new
RenderWindowclass that encapsulates Pygame initialization and window management, providing a clean and modular interface for rendering applications.What's New
RenderWindowClassA new
render_window.pymodule provides theRenderWindowclass with the following features:pygame.init(), window creation, and display configurationget_surface()- Access the display surface for renderingshould_continue()- Process events and check if the window should remain opentick(fps)- Control frame rateregister_event_handler(handler)- Add custom event handlersUsage Examples and Documentation
Added
render_window_example.pywith three complete working examples demonstrating:main.pyto use RenderWindow with the existingGraphikclassUpdated
README.mdwith a dedicated RenderWindow section including feature overview, basic usage example, and reference to the example file.Usage Example
Composition Pattern
The class is designed for composition, making it easy to integrate into existing applications:
Benefits
Additional Changes
.gitignoreto exclude__pycache__/directoriesrender_window_example.pywith three usage examplesREADME.mdwith RenderWindow documentationTesting
The implementation has been thoroughly tested with:
Resolves the issue requesting a
RenderWindowclass for managing Pygame initialization and enables modular, flexible use across multiple projects.Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.