Best way to determine user's screensize?

Peter J. Holzer hjp-python at hjp.at
Sat Oct 31 15:11:26 EDT 2020


On 2020-10-31 11:54:59 -0500, Igor Korot wrote:
> 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.
> If I can't set the initial size of the control in the appropriate layout
> system, then this is not a layout system.

Correct. But you and Chris and others were arguing that this size should
never be based on the screen size. Instead suggestions included "a guess"
and "a reasonable N".


> > 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.
> >
> 
> What is natural size? Please define this term.

Depends on the thing to be displayed of course.

For a JPG or PNG image, the "natural size" would be one image pixel =
one display pixel. Except that for small images on high dpi displays it
might be a "logical pixel" (is that the correct term?) instead.

For a a text, the natural size is a box around the complete text typeset
in the way it should be displayed.

Similarly for a list or a table.

A tree has two sizes that could be considered "natural": Fully collapsed
and fully expanded. But it will almost always be somewhere in between,
so that's another situation where a programmer would need to determine
what is reasonable.


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

Well. I haven't seen one which is smart enough. It might be because I
don't do desktop development (when I need a UI, I write a web app), but
I think the problem is (in general) unsolvable without domain knowledge,
and so far nobody has written anything to change my mind. I would need
to see either code or at least an explanation how this is done. "It just
works" is not a good argument for a techie.


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

Well, I have to agree with Chris here. Most programmers (especially
those who are paid big bucks) don't do proper designs.

        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/00d95368/attachment.sig>


More information about the Python-list mailing list