Best way to determine user's screensize?

Chris Angelico rosuav at gmail.com
Fri Oct 30 21:30:43 EDT 2020


On Sat, Oct 31, 2020 at 10:57 AM Peter J. Holzer <hjp-python at hjp.at> wrote:
>
> On 2020-10-31 10:02:12 +1100, Chris Angelico wrote:
> > On Sat, Oct 31, 2020 at 9:55 AM flaskee via Python-list
> > <python-list at python.org> wrote:
> > > I have done all of this resizing and layout stuff before.
> > >
> > > I just ignored the grouchy user with the hate over me wanting screensize.
> > > (every list has one of those types, eh? :-)
> > >
> > > Screensize, in part, determines the aspect ratio calcs to dynamically
> > > resize and place the components on the screen.
> > >
> >
> > So what would you do if it turns out that my screen is 5440 x 2104?
> > That's what mine is right now.
>
> That depends on the application.
>
> If for example the application is in image viewer and the image to be
> viewed is 4576x3432 pixels large, that wouldn't fit on the screen.
> Assuming 200 pixels of vertical chrome (title bar, window borders, menu
> bar and/or buttons), the image would have to be resized to (at most)
> 2539x1904 pixels. So the window would be sized to accommodate that.
>
> (If you use a multi-screen setup, the calculation should be based on
> the current screen, of course, not on the combined size of all screens)
>

But what is the "current screen"? That's the problem. MANY
applications (mostly games) decide to put themselves on monitor #4 and
size themselves according to monitor #1, or some other mismatching.
Or, I alt-tab away from something, come back in, and it resizes itself
to a different screen size.

There is no valid way for an application to read my mind and size
itself. Attempting to query my screen size seems to just make things
worse in a lot of situations.

ChrisA


More information about the Python-list mailing list