StaticBox with children

50 views
Skip to first unread message

werner

unread,
Sep 21, 2011, 1:45:31 PM9/21/11
to wxPytho...@googlegroups.com
In 2.9 controls within a staticbox can be children of it and no longer
need to be siblings.

When I do this (see attached) then tab traversal does no longer work -
or am I doing something wrong?

Werner

staticboxtest.py

Robin Dunn

unread,
Sep 21, 2011, 2:28:26 PM9/21/11
to wxpytho...@googlegroups.com

It looks like the static box needs to have the control container code
added to it so it can handle the tab traversal events. Please create a
trac ticket about this.

BTW, you have some other problems in your code. You are adding the
items that are children of the static box to the panel's sizer. You
should treat the static box (for layout related things) as if it was
just another panel. IOW, it should have it's own sizer for managing its
own children.

Also the wxStaticBoxSizer probably shouldn't be used in this case. Its
purpose is to manage the size of the box so it fits around the children
of the sizer. Since the box should have its own sizer assigned to it,
and since you can then just add the box directly to the parent's sizer,
then the wxStaticBoxSizer just becomes excess baggage.


--
Robin Dunn
Software Craftsman
http://wxPython.org

werner

unread,
Sep 21, 2011, 3:09:40 PM9/21/11
to wxpytho...@googlegroups.com
On 09/21/2011 08:28 PM, Robin Dunn wrote:
> On 9/21/11 10:45 AM, werner wrote:
>> In 2.9 controls within a staticbox can be children of it and no longer
>> need to be siblings.
>>
>> When I do this (see attached) then tab traversal does no longer work -
>> or am I doing something wrong?
>
> It looks like the static box needs to have the control container code
> added to it so it can handle the tab traversal events. Please create
> a trac ticket about this.
Will do - but see below.

>
> BTW, you have some other problems in your code. You are adding the
> items that are children of the static box to the panel's sizer. You
> should treat the static box (for layout related things) as if it was
> just another panel. IOW, it should have it's own sizer for managing
> its own children.
>
> Also the wxStaticBoxSizer probably shouldn't be used in this case.
> Its purpose is to manage the size of the box so it fits around the
> children of the sizer. Since the box should have its own sizer
> assigned to it, and since you can then just add the box directly to
> the parent's sizer, then the wxStaticBoxSizer just becomes excess
> baggage.
>
If I change it and treat SB like a panel then I tab traversal works, but
the static text box label is not shown.

Assuming that my code is ok this time then I think I should probably
report this one and maybe an error/warning/exception should be thrown if
one keeps using the SB sizer.

Or should I create two different tickets?

Werner

staticboxtest.py

werner

unread,
Sep 24, 2011, 4:20:24 AM9/24/11
to wxpytho...@googlegroups.com
On 09/21/2011 08:28 PM, Robin Dunn wrote:
> On 9/21/11 10:45 AM, werner wrote:
>> In 2.9 controls within a staticbox can be children of it and no longer
>> need to be siblings.
>>
>> When I do this (see attached) then tab traversal does no longer work -
>> or am I doing something wrong?
>
> It looks like the static box needs to have the control container code
> added to it so it can handle the tab traversal events. Please create
> a trac ticket about this.

Done - Ticket #13510


>
> BTW, you have some other problems in your code. You are adding the
> items that are children of the static box to the panel's sizer. You
> should treat the static box (for layout related things) as if it was
> just another panel. IOW, it should have it's own sizer for managing
> its own children.
>
> Also the wxStaticBoxSizer probably shouldn't be used in this case.
> Its purpose is to manage the size of the box so it fits around the
> children of the sizer. Since the box should have its own sizer
> assigned to it, and since you can then just add the box directly to
> the parent's sizer, then the wxStaticBoxSizer just becomes excess
> baggage.
>

I tried this but then the SB label doesn't show, mentioned it in the
above ticket and provided two different test files.

Werner

Reply all
Reply to author
Forward
0 new messages