What is a panel for?

snorble@hotmail.com wrote:

Conceptually, I'm not understanding what panels are used for. Most
examples in tutorials where panels are used, could just as easily have
been accomplished by just using sizers, I think. I'm sure there's a
good use for panels, I'm just trying to wrap my brain around it.

Panels are windows. Sizers are not. A panel can own other windows, so
that moving or disabling the panel affects its child windows. A sizer
can't do that. A sizer simply adjusts the windows that are under its
control. A panel can receive the focus and other window events. A
sizer, since it's not a window, cannot.

It's really two separate hierarchies. When you add a new control, it is
generally added to both a panel (to manage window ownership) and a sizer
(to manage size and position).

Consider a window with sliding splitter. You will want the two sides
treated differently, with two different sizers. To do that, you need to
add a panel on the left and a panel on the right, each with its own
sizer. Any child controls get added to a panel (for ownership) and to a
sizer (for size and position).

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Also, Panels are what provide the tab-traversal functionality. If you just put the widgets directly on a frame then the tab-traversal will not work correctly. (Although there are some exceptions to that in some circumstances...)

···

On 12/27/12 12:58 PM, Tim Roberts wrote:

snorble@hotmail.com wrote:

Conceptually, I'm not understanding what panels are used for. Most
examples in tutorials where panels are used, could just as easily have
been accomplished by just using sizers, I think. I'm sure there's a
good use for panels, I'm just trying to wrap my brain around it.

Panels are windows. Sizers are not. A panel can own other windows, so
that moving or disabling the panel affects its child windows. A sizer
can't do that. A sizer simply adjusts the windows that are under its
control. A panel can receive the focus and other window events. A
sizer, since it's not a window, cannot.

It's really two separate hierarchies. When you add a new control, it is
generally added to both a panel (to manage window ownership) and a sizer
(to manage size and position).

Consider a window with sliding splitter. You will want the two sides
treated differently, with two different sizers. To do that, you need to
add a panel on the left and a panel on the right, each with its own
sizer. Any child controls get added to a panel (for ownership) and to a
sizer (for size and position).

--
Robin Dunn
Software Craftsman

...

and to a sizer (for size and position).

and if you use wx.lib.sized_controls this bit is done automagically:) for you.

Werner

···

On 27/12/2012 21:58, Tim Roberts wrote: