[wxPython] labelled text entry widget

Hi there

I think that Riann put something like this into Boa a while ago. Perhaps not
quite so sophisticated as what you are after, but perhaps a start.

Cheers

Lynndon Harnell

···

-----Original Message-----
From: Magnus Lyckå [mailto:magnus@thinkware.se]
Sent: Tuesday, 12 February 2002 10:05 PM
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] labelled text entry widget

At 22:23 2002-02-12 +1100, Horst wrote:

Has anybody ever written a nice "labelled text entry" class?
I mean, the situation of having a text enty widget associated with a
static text label is quite common, yet we always need to go through the
cumbersome process of doing something like:

[cumbersome process snipped]

Agreed!

If nobody has done it yet, I would do it.

Thank's Horst. Great!

Of course, the advantage of defining the separately is that you can
get the alignment just the way you like it... You might want the
label above the text entry like this:

Spam
[________]

or before, like this:

Spam [________]

If you want several entry fields, you probably want them aligned,
not just the labels. (Proper viewing of text below required non
proportional font).

E.g. you don't want:
Name [__________]
Adress [_______________]
Phone [_________]

But rather:
Name [__________]
Adress [_______________]
Phone [_________]

Or maybe:
   Name [__________]
Adress [_______________]
  Phone [_________]

I haven't played around enough with layout to know
how difficult this is to solve so that it works
right with sizers etc.

My first thought was that one would need to have
some kind of anchor on the beginning of the entry
field to align by, but then I realized that it
might be ok just to specify a big enough width
for the label. Then it shouldn't be so bad.

I've have some clients who would probably give
comments such as wanting the label to be 0.7 mm
closer to the entry field... :frowning:

Then you have the issue of vertical alignment. My
experience is that you might have to fiddle a bit
with these things. It usually works best with
wxALIGN_CENTER_VERTICAL in my wxPython experience,
but NOT if you have a multi line entry field I guess...
But if you can make something that works well with
only single lines, it's a good start.

I guess it would be a good thing if this combo
widget would somehow encapsulate all the functionality
in the normal two-controls-and-sizer solution so
that there are good defaults, but if I want some
variation on exact label location etc, I can make
a subclass of your control and use that through out
my design. I'd love to be able to change *all* my labels
to be left aligned, bold, in a different font, or two
pixels closer to the entry control by making a change
in just one place in the code.

--
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

Hello,

The control is independent from Boa, you may get it from here:

"Harnell, Lynndon" wrote:

···

Hi there

I think that Riann put something like this into Boa a while ago. Perhaps not
quite so sophisticated as what you are after, but perhaps a start.

Cheers

Lynndon Harnell

-----Original Message-----
From: Magnus Lyckå [mailto:magnus@thinkware.se]
Sent: Tuesday, 12 February 2002 10:05 PM
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] labelled text entry widget

At 22:23 2002-02-12 +1100, Horst wrote:
>Has anybody ever written a nice "labelled text entry" class?
>I mean, the situation of having a text enty widget associated with a
>static text label is quite common, yet we always need to go through the
>cumbersome process of doing something like:
[cumbersome process snipped]

Agreed!

>If nobody has done it yet, I would do it.

Thank's Horst. Great!

Of course, the advantage of defining the separately is that you can
get the alignment just the way you like it... You might want the
label above the text entry like this:

Spam
[________]

or before, like this:

Spam [________]

If you want several entry fields, you probably want them aligned,
not just the labels. (Proper viewing of text below required non
proportional font).

E.g. you don't want:
Name [__________]
Adress [_______________]
Phone [_________]

But rather:
Name [__________]
Adress [_______________]
Phone [_________]

Or maybe:
   Name [__________]
Adress [_______________]
  Phone [_________]

I haven't played around enough with layout to know
how difficult this is to solve so that it works
right with sizers etc.

My first thought was that one would need to have
some kind of anchor on the beginning of the entry
field to align by, but then I realized that it
might be ok just to specify a big enough width
for the label. Then it shouldn't be so bad.

I've have some clients who would probably give
comments such as wanting the label to be 0.7 mm
closer to the entry field... :frowning:

Then you have the issue of vertical alignment. My
experience is that you might have to fiddle a bit
with these things. It usually works best with
wxALIGN_CENTER_VERTICAL in my wxPython experience,
but NOT if you have a multi line entry field I guess...
But if you can make something that works well with
only single lines, it's a good start.

I guess it would be a good thing if this combo
widget would somehow encapsulate all the functionality
in the normal two-controls-and-sizer solution so
that there are good defaults, but if I want some
variation on exact label location etc, I can make
a subclass of your control and use that through out
my design. I'd love to be able to change *all* my labels
to be left aligned, bold, in a different font, or two
pixels closer to the entry control by making a change
in just one place in the code.

--
Magnus Lyckå, Thinkware AB
Älvans väg 99, SE-907 50 UMEÅ
tel: 070-582 80 65, fax: 070-612 80 65
http://www.thinkware.se/ mailto:magnus@thinkware.se

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
Riaan Booysen
___________________________________________________
Boa Constructor - RAD GUI building IDE for wxPython
     http://boa-constructor.sourceforge.net

Thanks . Unfortunately, it does not work at all with sizers (caption never
gets displayed). Looking at the source code, I can see that there is no
way the sizer could tell the size of the combined control anyway.

Horst

···

On Wednesday 13 February 2002 09:13, Riaan Booysen wrote:

Hello,

The control is independent from Boa, you may get it from here:

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boa-constructo
r/boa/bcrtl/user/StaticTextCtrl.py

P.S.: In order to make Riaans class work in conjunction with sizers, would
it be enough to just override Fit(), GetSize(), GetGetClientSize(),
GetPosition(), getRect() or does it involve more (or maybe even less?)
than that?

Horst

···

On Wednesday 13 February 2002 13:12, Horst Herb wrote:

On Wednesday 13 February 2002 09:13, Riaan Booysen wrote:
> Hello,
>
> The control is independent from Boa, you may get it from here:
>
> http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/boa-construc
>to r/boa/bcrtl/user/StaticTextCtrl.py

Thanks . Unfortunately, it does not work at all with sizers (caption
never gets displayed). Looking at the source code, I can see that there
is no way the sizer could tell the size of the combined control anyway.

> >
> > The control is independent from Boa, you may get it from here:
> >
> > Best Open Source Mac Software 2024
> >to r/boa/bcrtl/user/StaticTextCtrl.py
>
> Thanks . Unfortunately, it does not work at all with sizers (caption
> never gets displayed). Looking at the source code, I can see that there
> is no way the sizer could tell the size of the combined control anyway.

P.S.: In order to make Riaans class work in conjunction with sizers, would
it be enough to just override Fit(), GetSize(), GetGetClientSize(),
GetPosition(), getRect() or does it involve more (or maybe even less?)
than that?

No, unfotunatly that won't work. In order for methods to be overridable in
Python and also be callable from C++ there must be some special
implementation work done in the wrappers. This adds a fair amount of
overhead and a lot of complexity so I usually only do it where it is
necessary for the normal use of the class.

To get StaticTextCtrl to work well with sizers then the window it derives
from will have to encompas the whole combination, instead of just part of
it. For example if it derived from wxPanel and then layed out the static
text and the text ctrl on the panel. This is how the filebrowsebutton in
wxPython/lib is done.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!