Observation
RenderWindow.__init__ calls pygame.init(), but the class exposes no corresponding teardown. Every caller is therefore left to call pygame.quit() itself, which is what all three examples in render_window_example.py do:
while window.should_continue():
...
pygame.quit()
This makes the API asymmetric: setup is encapsulated, cleanup is not.
Suggested change
A close() (or quit()) method should be added that calls pygame.quit() and marks the window as no longer running. Support for the context-manager protocol (__enter__ / __exit__) would additionally allow the following, which removes the possibility of a caller forgetting the teardown:
with RenderWindow("Title", 800, 600) as window:
while window.should_continue():
...
Once such a method exists, the examples in render_window_example.py and the snippet in README.md should be updated to use it rather than calling pygame.quit() directly.
Notes
This gap was identified while PR #10 was reviewed, and was deliberately not addressed there in order to keep that PR scoped to the API named in issue #6. It is covered by mocked unit tests, so no live Viron server is needed to validate a fix.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
Observation
RenderWindow.__init__callspygame.init(), but the class exposes no corresponding teardown. Every caller is therefore left to callpygame.quit()itself, which is what all three examples inrender_window_example.pydo:This makes the API asymmetric: setup is encapsulated, cleanup is not.
Suggested change
A
close()(orquit()) method should be added that callspygame.quit()and marks the window as no longer running. Support for the context-manager protocol (__enter__/__exit__) would additionally allow the following, which removes the possibility of a caller forgetting the teardown:Once such a method exists, the examples in
render_window_example.pyand the snippet inREADME.mdshould be updated to use it rather than callingpygame.quit()directly.Notes
This gap was identified while PR #10 was reviewed, and was deliberately not addressed there in order to keep that PR scoped to the API named in issue #6. It is covered by mocked unit tests, so no live Viron server is needed to validate a fix.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson