[wxPython-users] A "labeled widget"?
Christopher Barker
Chris.Barker at noaa.gov
Mon Aug 7 14:15:42 PDT 2006
Gavana, Andrea wrote:
> No, I have never thought about something like that... You mean, the =
> statictext and the main control should behave like a single widget?
Pretty much.
> Uhm, I honestly wouldn't know where to start except from sizers, as =
> you previously did. Otherwise, the only alternative I see is to write
> a custom control (but for a wx.TextCtrl and wx.Choice it would be a =
> pain to implement their functionalities).
I sort of started that way, putting the desired control and the
StaticText on a Panel, but then I had to figure out haw to get the event
binding right (not too hard), then I realized that I needed to get the
attribute resolution right, etc, etc. -- it started getting ugly.
I re-thought, and i realized that I don't really need them to behave
like a single widget in all ways -- only as far as layout is concerned.
So I made a factory function that creates a Sizer from an already
created control and the label text. It puts them in a BoxSizer, and
returns that. You can then drop that into another sizer like a single
object.
I've enclosed the code -- there's not much to it. It works for my needs
at the moment, but I think it might be worth making more robust and
complete in the future. I now it has greatly simplified my sizer layout
that I had for a bunch of wx.Choices in a FlexGridSizer.
The main issue I had was that I needed a different amount of space
between the label and the widget as I needed between the different
widgets. to accomplish this, I needed to put in columns that were just
spacers, it got ugly.
I've enclosed a png of what I have now. the issue here is that the
labels are sized independently, so they don't line up, but that works
for me here. I can't think of a way to fix that right now
> However, it seems to me that the work Kevin is doing may help us
> greatly regarding sizers.
I think so too, but I wasn't struggling with the sizer layout -- I was
struggling with the fact that I had a label and a widget that belonged
together, but putting them in a sizer didn't respect that. If I wanted
to switch around the layout (which I did), I needed to remember to move
the label, the widget, and the spacers.
neptune321 at excite.com wrote:
> Here's something I put together a LOOONNNG time ago - not sure I'd do
> it the same way today, but...
That's close to what I had in mind, but I realized I'd be happier of I =
could make a generic one, rather than one for each type of widget I =
might need.
Let me know what you all think.
-Chris
-- =
Christopher Barker, Ph.D.
Oceanographer
=
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: junk.png
Type: image/png
Size: 8051 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20060=
807/78c3a585/junk.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: LabeledWindow.py
Type: text/x-python
Size: 4763 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20060=
807/78c3a585/LabeledWindow.py
More information about the wxpython-users
mailing list