Generating Layouts, Can't access Sizers

I am working on an automatic layout algorithm, generating controls and
placing them in boxsizers.

When I find a control and call GetSizer(), the program returns None.
Even after layout.

In the WIT, I can select the control, see it's in a boxsizer, and
obj.GetSizer() returns None.

System and wx versions:
2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
2.8.10.1 (msw-unicode)

What circumstances could prevent GetSizer() from returning the actual
sizer? Or, has it been so long since I worked with this I've forgotten
something vital?

I have a created a sample app that is giving the same grief.

GetSizerFAIL.py (1.16 KB)

···

--
Josh English
Joshua.R.English@gmail.com
http://joshenglish.livejournal.com

obj.GetSizer gives you the sizer used to manage the layout obj's children, not the layout of obj and its siblings on their parent. If that is what you want then use GetContainingSizer.

···

On 10/21/10 11:30 AM, Josh English wrote:

I am working on an automatic layout algorithm, generating controls and
placing them in boxsizers.

When I find a control and call GetSizer(), the program returns None.
Even after layout.

In the WIT, I can select the control, see it's in a boxsizer, and
obj.GetSizer() returns None.

System and wx versions:
2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
2.8.10.1 (msw-unicode)

What circumstances could prevent GetSizer() from returning the actual
sizer? Or, has it been so long since I worked with this I've forgotten
something vital?

--
Robin Dunn
Software Craftsman

Consider this dope slapped in the back of the head.

I went back and played with GetSizer and finally trolled the Get_
methods in the WIT to find this one.

Thanks.

Josh

···

On Thu, Oct 21, 2010 at 11:38 AM, Robin Dunn <robin@alldunn.com> wrote:

On 10/21/10 11:30 AM, Josh English wrote:

I am working on an automatic layout algorithm, generating controls and
placing them in boxsizers.

When I find a control and call GetSizer(), the program returns None.
Even after layout.

In the WIT, I can select the control, see it's in a boxsizer, and
obj.GetSizer() returns None.

System and wx versions:
2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
2.8.10.1 (msw-unicode)

What circumstances could prevent GetSizer() from returning the actual
sizer? Or, has it been so long since I worked with this I've forgotten
something vital?

obj.GetSizer gives you the sizer used to manage the layout obj's children,
not the layout of obj and its siblings on their parent. If that is what you
want then use GetContainingSizer.

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

Okay, now I have a follow-up.

What I want to do is change the sizer proportion and flag after layout. (This is
a generated layout and I want to tweak certain bits.)

I see the control is in a sizer, which has children of sizeritems. Is
it possible
to get that SizerItem and change the proportion flag?

I've got a heirarchy of box sizers, so if I want to add the wx.GROW flag to one
control, I need to add it to the SizerItem, and the Sizer, don't I?

Josh

···

On Thu, Oct 21, 2010 at 11:40 AM, Josh English <joshua.r.english@gmail.com> wrote:

Consider this dope slapped in the back of the head.

I went back and played with GetSizer and finally trolled the Get_
methods in the WIT to find this one.

Thanks.

Josh

On Thu, Oct 21, 2010 at 11:38 AM, Robin Dunn <robin@alldunn.com> wrote:

On 10/21/10 11:30 AM, Josh English wrote:

I am working on an automatic layout algorithm, generating controls and
placing them in boxsizers.

When I find a control and call GetSizer(), the program returns None.
Even after layout.

In the WIT, I can select the control, see it's in a boxsizer, and
obj.GetSizer() returns None.

System and wx versions:
2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)]
2.8.10.1 (msw-unicode)

What circumstances could prevent GetSizer() from returning the actual
sizer? Or, has it been so long since I worked with this I've forgotten
something vital?

obj.GetSizer gives you the sizer used to manage the layout obj's children,
not the layout of obj and its siblings on their parent. If that is what you
want then use GetContainingSizer.

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com
http://joshenglish.livejournal.com

--
Josh English
Joshua.R.English@gmail.com

Something like this should work:

  item = sizer.GetItem(widget)
  if item:
    # changing flags
    item.SetFlag(item.GetFlag()|wx.GROW)

    # or changing the proportion
    item.SetProportion(2)

···

On 10/21/10 11:54 AM, Josh English wrote:

Okay, now I have a follow-up.

What I want to do is change the sizer proportion and flag after layout. (This is
a generated layout and I want to tweak certain bits.)

I see the control is in a sizer, which has children of sizeritems. Is
it possible
to get that SizerItem and change the proportion flag?

I've got a heirarchy of box sizers, so if I want to add the wx.GROW flag to one
control, I need to add it to the SizerItem, and the Sizer, don't I?

--
Robin Dunn
Software Craftsman

Arg. And I mean this from the bottom of my heart.

Currently, wxPython is telling me wx.GROW and wx.EXPAND are both 8192.
Shouldn't they be different values?

Josh

···

On Thu, Oct 21, 2010 at 12:08 PM, Robin Dunn <robin@alldunn.com> wrote:

On 10/21/10 11:54 AM, Josh English wrote:

Okay, now I have a follow-up.

What I want to do is change the sizer proportion and flag after layout.
(This is
a generated layout and I want to tweak certain bits.)

I see the control is in a sizer, which has children of sizeritems. Is
it possible
to get that SizerItem and change the proportion flag?

I've got a heirarchy of box sizers, so if I want to add the wx.GROW flag
to one
control, I need to add it to the SizerItem, and the Sizer, don't I?

Something like this should work:

   item = sizer\.GetItem\(widget\)
   if item:
           \# changing flags
           item\.SetFlag\(item\.GetFlag\(\)|wx\.GROW\)

           \# or changing the proportion
           item\.SetProportion\(2\)

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

No, they both have the same operation and are just synonyms, like wx.Colour/Color

···

On 22/10/2010 00:02, Josh English wrote:

Arg. And I mean this from the bottom of my heart.

Currently, wxPython is telling me wx.GROW and wx.EXPAND are both 8192.
Shouldn't they be different values?

Josh

On Thu, Oct 21, 2010 at 12:08 PM, Robin Dunn<robin@alldunn.com> wrote:

On 10/21/10 11:54 AM, Josh English wrote:

Okay, now I have a follow-up.

What I want to do is change the sizer proportion and flag after layout.
(This is
a generated layout and I want to tweak certain bits.)

I see the control is in a sizer, which has children of sizeritems. Is
it possible
to get that SizerItem and change the proportion flag?

I've got a heirarchy of box sizers, so if I want to add the wx.GROW flag
to one
control, I need to add it to the SizerItem, and the Sizer, don't I?

Something like this should work:

        item = sizer.GetItem(widget)
        if item:
                # changing flags
                item.SetFlag(item.GetFlag()|wx.GROW)

                # or changing the proportion
                item.SetProportion(2)

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Steven Sproat, BSc
http://www.whyteboard.org/

I thought one was supposed to expand to fill the available space, and
the other automatically grow the control when the window size changes.

Josh

···

On Thu, Oct 21, 2010 at 5:18 PM, Steven Sproat <sproaty@gmail.com> wrote:

On 22/10/2010 00:02, Josh English wrote:

Arg. And I mean this from the bottom of my heart.

Currently, wxPython is telling me wx.GROW and wx.EXPAND are both 8192.
Shouldn't they be different values?

Josh

On Thu, Oct 21, 2010 at 12:08 PM, Robin Dunn<robin@alldunn.com> wrote:

On 10/21/10 11:54 AM, Josh English wrote:

Okay, now I have a follow-up.

What I want to do is change the sizer proportion and flag after layout.
(This is
a generated layout and I want to tweak certain bits.)

I see the control is in a sizer, which has children of sizeritems. Is
it possible
to get that SizerItem and change the proportion flag?

I've got a heirarchy of box sizers, so if I want to add the wx.GROW flag
to one
control, I need to add it to the SizerItem, and the Sizer, don't I?

Something like this should work:

   item = sizer\.GetItem\(widget\)
   if item:
           \# changing flags
           item\.SetFlag\(item\.GetFlag\(\)|wx\.GROW\)

           \# or changing the proportion
           item\.SetProportion\(2\)

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

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

No, they both have the same operation and are just synonyms, like
wx.Colour/Color

--
Steven Sproat, BSc
http://www.whyteboard.org/

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

See this thread from April:

https://groups.google.com/group/wxpython-users/browse_thread/thread/51133dbbcc7343c0/dba8fd3d160969fb?lnk=gst&q=+GROW+vs+EXPAND#dba8fd3d160969fb

···

On Thu, Oct 21, 2010 at 8:40 PM, Josh English <joshua.r.english@gmail.com> wrote:

I thought one was supposed to expand to fill the available space, and
the other automatically grow the control when the window size changes.

Got it. I get, now, that changing the proportion will do what I want.

Sadly, I can't figure out how to climb the sizer-hierarchy.

Here's the layout of my window:

Frame
- panel
--box sizer (vertical)
---staticbox sizer (vertical)
---box sizer (horizontal)
----TextCtrl to change.

If I change the TextCtrl, buried three sizers into the layout, I can
get its containing sizer, and the sizer item that controls it, but
that's it.

I need to also change the sizeritem in the staticboxsizer that
contains the box sizer that contains the control, otherwise changing
the proportion on the sizeritem containing the control doesn't do
enough.

Unless there's a secret method, I have to recreate the sizer tree.

And as these sizers and controls are being generated by another
script, I can't create them this way, I need to tweak them after
creation and layout.

Josh

···

On Thu, Oct 21, 2010 at 7:02 PM, C M <cmpython@gmail.com> wrote:

On Thu, Oct 21, 2010 at 8:40 PM, Josh English > <joshua.r.english@gmail.com> wrote:

I thought one was supposed to expand to fill the available space, and
the other automatically grow the control when the window size changes.

See this thread from April:

https://groups.google.com/group/wxpython-users/browse_thread/thread/51133dbbcc7343c0/dba8fd3d160969fb?lnk=gst&q=+GROW+vs+EXPAND#dba8fd3d160969fb

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

--
Josh English
Joshua.R.English@gmail.com

Even better, I think I sussed it for my purposes.

It creates the tree of sizers and then can change them.

In this sample, it's dynamic, but in the real application, it will
happen automatically.

ChangeSizerProportion.py (2.82 KB)

···

--
Josh English
Joshua.R.English@gmail.com
http://joshenglish.livejournal.com

There are a number of flag constant synonyms for BoxSizers. See the wiki page :

BoxSizerFromTheGroundUp

Note that in wx.Python there is the method .SetBackgroundColour() but no synonym .SetBackgroundColor(). The same is true for the class variable ctrl**.BackgroundColour** and ctrl**.BackgroundColor**

···

On Thu, Oct 21, 2010 at 5:18 PM, Steven Sproat sproaty@gmail.com wrote:

On 22/10/2010 00:02, Josh English wrote:

Arg. And I mean this from the bottom of my heart.

Currently, wxPython is telling me wx.GROW and wx.EXPAND are both 8192.
Shouldn’t they be different values?

No, they both have the same operation and are just synonyms, like

wx.Colour/Color

I was just about to reply to your previous message to suggest doing a recursive traversal using sizer.GetChildren. You read my mind. :wink:

···

On 10/21/10 11:46 PM, Josh English wrote:

Even better, I think I sussed it for my purposes.

It creates the tree of sizers and then can change them.

In this sample, it's dynamic, but in the real application, it will
happen automatically.

--
Robin Dunn
Software Craftsman