Closed BloodyRain2k closed 1 year ago
While fixing the oversight of expecting geometry
to be set, I've noticed something odd: if only height
and width
are set, winfo_reqwidth()
and winfo_reqheight()
will return those values before window init, but the window will not end up using them at all.
I thought at first that my code of setting geometry
without a size and only a position was the cause for that, but even when I left that last line out, the window reported to be "800x600" (which is what I did set in it's .ui
), only to appear as 300x200 or something, for whatever reason.
Hello @BloodyRain2k, sorry for the late response.
I like the type hints for variables.
But to center the window, I'd like to use this other approach that I show in this example:
This waits until the Map event occurs. At this time the sizes are known and the center calculation can be done more clear.
While fixing the oversight of expecting
geometry
to be set, I've noticed something odd: if onlyheight
andwidth
are set,winfo_reqwidth()
andwinfo_reqheight()
will return those values before window init, but the window will not end up using them at all.I thought at first that my code of setting
geometry
without a size and only a position was the cause for that, but even when I left that last line out, the window reported to be "800x600" (which is what I did set in it's.ui
), only to appear as 300x200 or something, for whatever reason.
Regarding this problem. The configured width and height for container widgets, depends on the layout manager used. Pack and Grid does not allow the user to force a width o height (unless you set the propagate property to False) So, if you have a Toplevel configured with widht=800 height=600 and no geometry set, the manager used for the children will configure the size of the window at his will. The only way to force the size of a Toplevel widget is to use the geometry property.
Let me know. Regards
I've removed my centering code from the PR and I'll play around with the code you linked later.
I remember that I've seen some window centering code which did center the window too, but it made the window appear in the default position for a few frames first, which irritated me.
I wanted some type hinting support for the defined TkVars in VSCode, so I've expanded the
app
andscript
mako files for that.And I also found it way to bothersome to write some code that (optionally) centers the window upon creation, so I've added that to the mako files as well.
This is what it then looks like for variables: