2.9.3 and StaticBox

I'll start a new thread instead of hijacking Che's.

I was confused on how this should work in 2.9.3, thought controls should be siblings and not children.

So, based on previous posts and looking at the wxPhoenix doc I understand that in 2.9.3 the recommended way is:

- parent
-- StaticBox
--- BoxSizer with SetSizer(staticbox)
---- controls as children of StaticBox and added to BoxSizer

In 2.9.3.1 on Win this doesn't work for me, unless I still haven't had enough coffee;-) .

Attached is what I did and the problem is that the StaticBox does not wrap the children, instead there is some overlap.

Can anyone see what I am doing wrong on this?

Werner

P.S.
Also tried it without sized controls, but still same issue.

staticboxanddoublebuffer.py (1.78 KB)

It looks - based on a quick scan as if you are not adding the controls
to the/any sizer.

AFAIK you need to add controls to the sizer for it to lay them out.

Gadget/Steve

···

On 25/04/2012 11:12 AM, Werner wrote:

I'll start a new thread instead of hijacking Che's.

I was confused on how this should work in 2.9.3, thought controls
should be siblings and not children.

So, based on previous posts and looking at the wxPhoenix doc I
understand that in 2.9.3 the recommended way is:

- parent
-- StaticBox
--- BoxSizer with SetSizer(staticbox)
---- controls as children of StaticBox and added to BoxSizer

In 2.9.3.1 on Win this doesn't work for me, unless I still haven't had
enough coffee;-) .

Attached is what I did and the problem is that the StaticBox does not
wrap the children, instead there is some overlap.

Can anyone see what I am doing wrong on this?

Werner

P.S.
Also tried it without sized controls, but still same issue.

Ooops - having taken a look at the docs ignore the above but I noticed
that you are calling

staticB.SetSizerProps rather than paneSSBC.SetSizerProps
and that the expand parameter has a value of 1 rather than True - don't know that will help.

Gadget/Steve

···

On 25/04/2012 11:24 AM, Gadget/Steve wrote:

On 25/04/2012 11:12 AM, Werner wrote:

I'll start a new thread instead of hijacking Che's.

I was confused on how this should work in 2.9.3, thought controls
should be siblings and not children.

So, based on previous posts and looking at the wxPhoenix doc I
understand that in 2.9.3 the recommended way is:

- parent
-- StaticBox
--- BoxSizer with SetSizer(staticbox)
---- controls as children of StaticBox and added to BoxSizer

In 2.9.3.1 on Win this doesn't work for me, unless I still haven't had
enough coffee;-) .

Attached is what I did and the problem is that the StaticBox does not
wrap the children, instead there is some overlap.

Can anyone see what I am doing wrong on this?

Werner

P.S.
Also tried it without sized controls, but still same issue.

It looks - based on a quick scan as if you are not adding the controls
to the/any sizer.

AFAIK you need to add controls to the sizer for it to lay them out.

Gadget/Steve

Hi Steve,

I'll start a new thread instead of hijacking Che's.

I was confused on how this should work in 2.9.3, thought controls
should be siblings and not children.

So, based on previous posts and looking at the wxPhoenix doc I
understand that in 2.9.3 the recommended way is:

- parent
-- StaticBox
--- BoxSizer with SetSizer(staticbox)
---- controls as children of StaticBox and added to BoxSizer

In 2.9.3.1 on Win this doesn't work for me, unless I still haven't had
enough coffee;-) .

Attached is what I did and the problem is that the StaticBox does not
wrap the children, instead there is some overlap.

Can anyone see what I am doing wrong on this?

Werner

P.S.
Also tried it without sized controls, but still same issue.

It looks - based on a quick scan as if you are not adding the controls
to the/any sizer.

AFAIK you need to add controls to the sizer for it to lay them out.

Gadget/Steve

Ooops - having taken a look at the docs ignore the above but I noticed
that you are calling

staticB.SetSizerProps rather than paneSSBC.SetSizerProps

Wouldn't have that normally as the SB should just use enough space to wrap its children.

  and that the expand parameter has a value of 1 rather than True - don't know that will help.

Doesn't make a difference.

Anyhow, thanks for looking at it.

Werner

···

On 25/04/2012 12:41, Gadget/Steve wrote:

On 25/04/2012 11:24 AM, Gadget/Steve wrote:

On 25/04/2012 11:12 AM, Werner wrote:

Until wx.StaticBox is doing something smarter about its client size and origin than using the same size as the whole widget then you'll need to compensate by adding some border space to the item(s) added to the staticbox's sizer.

It looks like at least wxOSX-Cocoa is already adjusting the client size, but wxMSW is not. So you can probably use a test something like this to know if you need to add some border space:

  if sbox.Size == sbox.ClientSize:
    # add some border space to the items

···

On 4/25/12 3:12 AM, Werner wrote:

I'll start a new thread instead of hijacking Che's.

I was confused on how this should work in 2.9.3, thought controls should
be siblings and not children.

So, based on previous posts and looking at the wxPhoenix doc I
understand that in 2.9.3 the recommended way is:

- parent
-- StaticBox
--- BoxSizer with SetSizer(staticbox)
---- controls as children of StaticBox and added to BoxSizer

In 2.9.3.1 on Win this doesn't work for me, unless I still haven't had
enough coffee;-) .

Attached is what I did and the problem is that the StaticBox does not
wrap the children, instead there is some overlap.

Can anyone see what I am doing wrong on this?

Werner

P.S.
Also tried it without sized controls, but still same issue.

--
Robin Dunn
Software Craftsman

Hi Robin,

...

Until wx.StaticBox is doing something smarter about its client size and origin than using the same size as the whole widget then you'll need to compensate by adding some border space to the item(s) added to the staticbox's sizer.

It looks like at least wxOSX-Cocoa is already adjusting the client size, but wxMSW is not. So you can probably use a test something like this to know if you need to add some border space:

    if sbox.Size == sbox.ClientSize:
        # add some border space to the items

Had a go at it, add additional border and add a spacer at the top to push things down, looks fine. BUT, I can't get the StaticBox to size just large enough arounds its children. If I expand and use proportion=1 I can see the children correctly placed, but it is obviously not what I want as the overall control is too large.

Will the fix to StaticBox be in the next 2.9.x release? If it is I will wait for that.

Thanks
Werner

···

On 26/04/2012 01:17, Robin Dunn wrote:

I've brought the issue up on wx-dev. We'll see.

···

On 4/26/12 12:47 AM, Werner wrote:

Hi Robin,

On 26/04/2012 01:17, Robin Dunn wrote:
...

Until wx.StaticBox is doing something smarter about its client size
and origin than using the same size as the whole widget then you'll
need to compensate by adding some border space to the item(s) added to
the staticbox's sizer.

It looks like at least wxOSX-Cocoa is already adjusting the client
size, but wxMSW is not. So you can probably use a test something like
this to know if you need to add some border space:

if sbox.Size == sbox.ClientSize:
# add some border space to the items

Had a go at it, add additional border and add a spacer at the top to
push things down, looks fine. BUT, I can't get the StaticBox to size
just large enough arounds its children. If I expand and use proportion=1
I can see the children correctly placed, but it is obviously not what I
want as the overall control is too large.

Will the fix to StaticBox be in the next 2.9.x release? If it is I will
wait for that.

--
Robin Dunn
Software Craftsman