Best way to determine user's screensize?

Peter J. Holzer hjp-python at hjp.at
Sat Oct 31 09:37:52 EDT 2020


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). 

Very often this is not the case: An image viewer will be used to display
images which are larger than the screen. A MUA may have to display
hundreds of mailboxes, and maybe tens of thousands of mails in a single
mailbox. 

In these cases an application can't use the "natural size": It would be
bigger than the screen, and depending on the window manager, the user
might not even be able to resize it because the handles are off-screen.

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.)

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.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp at hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mail.python.org/pipermail/python-list/attachments/20201031/7aab07a2/attachment.sig>


More information about the Python-list mailing list