[wxPython-users] Panel on top of Staticbox
Robin Dunn
robin at alldunn.com
Tue Mar 4 12:51:50 PST 2008
L. Fanchi wrote:
> Hello,
>
> I want to place a panel on top a Staticbox that is currently placed on
> another panel (contained in a Frame).
> The second panel displays properly, but underneath the Staticbox.
>
wx.StaticBox is a little weird in that the things that appear to be
within it are not supposed to be children if it like they would be for
other widget types. Instead the staticbox and the widgets it will
appear to contain should be siblings. In other words, they have the
same parent. Here is a little example:
import wx
class MainPanel(wx.Panel):
def __init__(self, *args, **kw):
wx.Panel.__init__(self, *args, **kw)
sb = wx.StaticBox(self, -1, "The StaticBox")
sbs = wx.StaticBoxSizer(sb, wx.VERTICAL)
otherPanel = wx.Panel(self)
otherPanel.SetBackgroundColour("pink")
sbs.Add(otherPanel, 1, wx.EXPAND)
sizer = wx.BoxSizer()
sizer.Add(sbs, 1, wx.EXPAND|wx.ALL, 30)
self.SetSizer(sizer)
app = wx.App(redirect=False)
frm = wx.Frame(None, title="Testing")
pnl = MainPanel(frm)
frm.Show()
app.MainLoop()
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list