Closed yoniLavi closed 2 years ago
This is not right because it's not fixing the bug that bf48fc964b5168d8e1e101a32adc2ac6cb685c69 was fixing, which is that the window needs to be destroyed after initialisation and reinitialised at the correct size. Resizing doesn't work because it doesn't trigger at least a couple of behaviours (icon setting and centering) that happen only when the window is first created.
This is all handled by temp_window()
in the non-IDE-mode path and I guess neglected in the IDE mode path. We should use temp_window, though I admit that it's hard to fit a context manager around a piece of code that is bookended by import pgzrun
and pgzrun.go()
; it either has to call __enter__
and __exit__
manually or use contextlib.ExitStack
.
Thanks for the additional information @lordmauve . Apologies, I'm new to the project and am apparently missing some important context. Could you please say more about the underling intent for bf48fc9 ? You said it fixes a bug, but I couldn't find mention of it in the commit. Is there some particular test/scenario that was failing?
And just to clarify your second paragraph there, the intent with this is to change the way IDE mode is run (e.g. as explained in https://pygame-zero.readthedocs.io/en/stable/ide-mode.html) to now require user code to be put inside a context manager? And if so, would it still be possible to run the same script in both IDE mode and non-IDE mode, or is that not an expectation?
I thought I replied to this. At least somewhere I have typed a partial reply, sadly my kids take up all my free time at the moment. I think I got sidetracked trying to identify the exact bug reports to link. So let me reply in brief now and look up the bug reports later.
There are several things that happen when pygame initialises a window that do not happen when it resizes a window:
So, creating a small window and resizing it means (1) the ICON
is not picked up and (2) the window appears off-center and possibly partly off-screen.
Commit bf48fc964b5168d8e1e101a32adc2ac6cb685c69 (Destroy temporary window after initial load) introduced a crash in convert_alpha() ("No video mode has been set") when using IDE mode. This commit brings back the original line of code setting the display mode.
The issue also mentions bringing back
PGZeroGame.show_default_icon()
, but I did not see a need for it.