Best way to determine user's screensize?

Chris Angelico rosuav at gmail.com
Sat Oct 31 14:19:18 EDT 2020


On Sun, Nov 1, 2020 at 4:10 AM Igor Korot <ikorot01 at gmail.com> wrote:
>
> Hi,
>
> On Sat, Oct 31, 2020, 8:40 AM Peter J. Holzer <hjp-python at hjp.at> wrote:
>
> > On 2020-10-31 07:51:38 -0500, 2QdxY4RzWzUUiLuE at potatochowder.com wrote:
> > > On 2020-10-31 at 13:02:03 +0100,
> > > "Peter J. Holzer" <hjp-python at hjp.at> wrote:
> > > > On 2020-10-31 12:30:43 +1100, Chris Angelico wrote:
> > > > > 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.
> > >
> > > > You still haven't answered the question: Where should the initial
> > > > window size come from? Does your window manager tell the application
> > > > how large a window should be? And if it does, can you as a user
> > > > configure that? I don't think mine (xfce) does that. (I guess tiling
> > > > WMs generally do that, but I've never used one.)
> > >
> > > The intial/default window should be big enough to contain the
> > > initial/default content, regardless of the configuration of the
> > > screen(s)/monitor(s).
> >
> > As I already wrote in an answer to Igor, this is only possible if the
> > initial/default content is of fixed size (or at least guaranteed to be
> > smaller than the screen size).
> >
>
> Any control at any given moment has a fixed size.

Yes - as determined by the layout manager, NOT the application.

> If I can't set the initial size of the control in the appropriate layout
> system, then this is not a layout system.

Sure, but the initial size should not be defined in pixels - it should
be defined by whatever makes logical sense ("a list box with room to
show these items").

> After the initial size is set it is up to the application to properly give
> the aspect ratio, font sizes, etc when the application is moved between the
> windows, resized, or DPI has changed, etc.

Why? Are you running on a potato where these kinds of basics aren't
handled by the window manager? Get a better window manager.

> > It could use some size which is small enough to fit on any screen (how
> > large is that? Can you assume 1366x768 these days?). But for most users
> > this would be annoying, since they would have to resize the window.
> >
> > (And note that "the user has to do than only once, the second time the
> > application can use the saved layout" doesn't hold either: The user may
> > have invoked the application on a large desktop monitor the first time,
> > but at some point they use the small laptop monitor or a projector.)
> >
>
> This is exactly my point.
> If the underlying toolkit is smart enough and the layout system is good
> then it won't matter.
>
>
> > I am very much a fan of letting layout and window managers do as much as
> > possible. But I don't think they can do everything. They simply don't
> > have the necessary information.
> >
>
> Of course not.
> Thats why software devs are paid big money to do proper designs.
>

And that's why the companies that pay big money to get software devs
to do "proper designs" inevitably end up with pixel-precise rigid
layouts that are utterly unusable on any system the devs didn't test
on.

Meanwhile, people like me - and several others who've posted in this
thread - take the lower-effort option that gives better results. We
define our layouts by rules, and allow the system to define the flow.
Pages like this might be a bit ugly, but I've spent maybe half an hour
working on the layout:

https://sikorsky.rosuav.com/hypetrain?for=devicat

The mobile version took me FAR more effort. I might have put... an
entire hour into this. Maybe even 90 minutes.

https://sikorsky.rosuav.com/hypetrain?for=devicat&mobile=1

Try those on different sizes of screens. Try them on different font
sizes, DPI settings, or anything else you care about. They might not
be the fanciest, they might not be the most showy, but they're not
much more ugly on any other system than they are on my own.

I do the same with desktop layouts too, although it's harder to
showcase that. My Dungeons & Dragons character sheet manager is
entirely rule-based in its GUI, with everything defined as "put a box
here labelled Attributes, and inside it, label/input pairs for STR,
DEX, INT, WIS, CON, CHA". It is *far* easier to maintain than
something where you have to manually lay everything out in pixel
positions.

Why do people get paid big money to make suboptimal designs? Because
the people paying them want something that looks good, not something
that can actually be used by everyone. Because actual usability
testing is incredibly rare. Because it's really hard to put a graph of
how annoyed your customers get with your web site onto a PowerPoint
slide.

ChrisA


More information about the Python-list mailing list