[wxPython-users] how to get the screen size for an application
Chris Mellon
arkanes at gmail.com
Wed Jan 3 08:51:12 PST 2007
On 1/3/07, vronskij <vronskij at gmail.com> wrote:
> >so will it also work if my controls are laid out manually on the
> >frame? for example if the frame is centered, what will it mean by
> >putting a button at point 0,0 on the centered frame?
> >wil it position itself relative to the starting point of the frame
> >(which will be some thing at the centerof the screen)?
>
> yes, it will work. the frame is centered on the screen desktop. the desktop
> background is just a kind of a special window. button at (0, 0) will stay at
> (0, 0), after the frame is centered on the screen.
>
>
> >I am not finding laying out controls with sizers a good technique (may
> >be I am wrong and correct me if so).
>
> usually the sizers are a better way to layout your widgets. there are
> situations, where manual layout fits well. ( many people would say, do not
> use manual layout at all, but I don't agree. ) I know Swing as well and I
> know exactly what you mean. I have
> heard countless of times people crying: swing layout managers are difficult
> to use!
> and the swing developers at sun replied: you can use Netbeans and their
> visual buider.
> Now you can see, how mysteries and myths are born. Swing layout managers are
> a bit more complicated, but it does not mean, they cannot be understood. the
> problem is only that there is not a complete and easy to understand tutorial
> or guide that would explain them. and that people are lazy. I bet the second
> reason is more relevant.
> Each developer must understand layout managers inside out. Couple of weeks
> studying them will pay off later on.
>
> If you are a master at Swing, wxPython is than a peace of cake. it is a way
> less complicated.
> I recommend you to look at wxPython code in some applications to get the
> -feeling-. So that
> you do not think in terms of Swing in wxPython.
>
> -jan bodnar
Absolute layouts are always wrong. Always. When you are using them,
you are not writing correct code, you are simply deciding that you
don't care about the cases where they don't work. It's very similar to
never freeing memory in C. Your program will work, but it is not
correct, and never will be correct, even if your users accept the
restrictions you place on them by making it incorrect (In the C case,
by buying more memory and rebooting the application often, in the
layout case by not changing fonts or resizing the window).
Thinking in terms of layouts rather than absolute positions is awkward
for people, but it can actually be simpler than absolute positions -
when you conceptualize a layout, you don't use coordinates. You think
something like "This should be to the left of this, and fill the
screen". You then convert that, in your head, to a coordinate rule,
and then finally you create and write in your code the actual
coordinate.
A layout system removes step 3 and formalizes step 2. The challenge is
to provide an API that maps as simple as possible from loose thoughts
like "to the left of this other control" to concrete mechanisms, while
maintaining the flexibility to support more complicated rules. It's a
hard problem and I haven't encountered a "good" API for it yet.
Being visually challenged makes it harder - not only can you not use
the variety of tools intended to isolate you from the complicated
APIs, you can't learn the API in the most straightforward way, which
is to change flags and settings and see how the application responds.
I don't have a good answer for you, and I'm sorry for that, and
perhaps absolute layouts are the best you can do - but they're still
wrong.
More information about the wxpython-users
mailing list