Sizers for Panels

I'm simply trying to place a button on a panel in a notebook page using sizers
to set placement, but I can't seem to find a sizer for a panel. What should
a sizer be applied to ? I've attached my script for reference.

Can anyone explain to a newbie the relationships between calls to
Addsizer, AddWindow, SetAutoLayout, SetSizer, Fit and SetSizeHints ?

Thanks--Ray

NOTEBOOK.PY (3.7 KB)

Ray Pasco wrote:

I'm simply trying to place a button on a panel in a notebook page using sizers
to set placement, but I can't seem to find a sizer for a panel. What should
a sizer be applied to ? I've attached my script for reference.

You can use any of the generic sizers (usually wxBoxSizer, but also wxGridSizer or wxFlexGridSizer) with a panel. Only notebooks require a specialized sizer.

Can anyone explain to a newbie the relationships between calls to
Addsizer, AddWindow, SetAutoLayout, SetSizer, Fit and SetSizeHints ?

AddSizer and AddWindow are methods of the generic sizers. box sizers can allocate space among multiple controls added to them with AddWindow. You can also nest box sizers (and I think the other generic sizers) inside each other to create more complicated layouts, by using AddSizer.

After adding windows to the sizer, you need to use SetSizer to attach the main sizer to the main window. Calling Fit shrinks the window to the minimum size to fit all the sizers and their controls (without a call to fit, the controls are adjusted to fit the size of the window). SetSizeHints (without Fit) tells the sizer not to shrink the controls below their current size.

David

Ray Pasco wrote:

I'm simply trying to place a button on a panel in a notebook page using sizers
to set placement, but I can't seem to find a sizer for a panel. What should
a sizer be applied to ? I've attached my script for reference.

you had a number of problems in your code:

Widgets on a panel use that panel (self) as their parent.

I'd avoid hard coded widget Ids ( use wxNewId() instead )

Can anyone explain to a newbie the relationships between calls to
Addsizer, AddWindow, SetAutoLayout, SetSizer, Fit and SetSizeHints ?

Someone else did a pretty good job of this already. Also be sure to read everything you can in the Wiki.

Enclosed is a version of your code that works...or at least does what I think you wanted!

junk.py (3.53 KB)

ยทยทยท

--
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@noaa.gov