dire straights with sizers: possible brain explosion

Hello,

I have a panel for which I can't get sizers to work, and my brain is near
fried. The problem is basically that a custom panel I have made runs fine,
sizer-wise, in a self test. But when I include it in another panel, the
sizer stuff doesn't work, and I just can't figure it out.

So there are two files, one is ~80 LOC, the other 160 LOC. I include here
only the first, since second one I think too large to post (but you need the
long one to run the first). Just send me an email or reply and I will send
you the second file directly. If you run both files you will see clearly,
one (not attached) has things well layed out, the other (included below)
creates a panel that is partially clipped.

Any help would be greatly appreciated or I might instantly discombobulate.
Thanks,

Oliver

# first file: DebugPanelSim.py
#Boa:FramePanel:PanelSim

from wxPython.wx import *

from DebugPanelSegNodes import PanelSegments

[wxID_PANELSIM, wxID_PANELSIMPANELSEGMENTSX, wxID_PANELSIMPANELSEGMENTSY,
wxID_PANELSIMSTATICBOX1,
] = map(lambda _init_ctrls: wxNewId(), range(4))

class PanelSim(wxPanel):
    _custom_classes = {'wxPanel':['PanelSegments']}
    
    def _init_sizers(self):
        # generated method, don't edit
        self.rootSizer = wxBoxSizer(orient=wxHORIZONTAL)
        self.staticBoxSizer1 = wxStaticBoxSizer(box=self.staticBox1,
              orient=wxVERTICAL)

        parent = self.rootSizer
        parent.AddSizer(self.staticBoxSizer1, 0, border=5, flag=wxALL |
wxGROW)
        parent = self.staticBoxSizer1
        parent.AddWindow(self.panelSegmentsX, 0, border=0,
              flag=wxALIGN_TOP | wxTOP | wxGROW)
        parent.AddWindow(self.panelSegmentsY, 0, border=0,
              flag=wxALIGN_TOP | wxGROW)

        self.SetSizer(self.rootSizer)

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wxPanel.__init__(self, id=wxID_PANELSIM, name='PanelSim',
parent=prnt,
              pos=wxPoint(590, 185), size=wxSize(163, 379),
              style=wxTAB_TRAVERSAL)
        self.SetClientSize(wxSize(155, 351))
        self.SetAutoLayout(True)

        self.panelSegmentsX = PanelSegments(id=wxID_PANELSIMPANELSEGMENTSX,
              name='panelSegmentsX', parent=self, pos=wxPoint(10, 18),
              size=wxSize(200, 162), style=wxTAB_TRAVERSAL)

        self.staticBox1 = wxStaticBox(id=wxID_PANELSIMSTATICBOX1,
              label='staticBox1', name='staticBox1', parent=self,
pos=wxPoint(5,
              5), size=wxSize(210, 341), style=0)

        self.panelSegmentsY = PanelSegments(id=wxID_PANELSIMPANELSEGMENTSY,
              name='panelSegmentsY', parent=self, pos=wxPoint(10, 180),
              size=wxSize(200, 161), style=wxTAB_TRAVERSAL)

        self._init_sizers()

    def __init__(self, parent, id, pos, size, style, name):
        self._init_ctrls(parent)
        
        self.panelSegmentsX.pushItem(None, '')
        self.panelSegmentsX.pushItem(None, '')
        self.panelSegmentsX.pushItem(None, '')

···

##
## self.panelSegmentsY.pushItem(None, '')
## self.panelSegmentsY.pushItem(None, '')

if __name__ == '__main__':
    class AppFrame(wxFrame):
        def __init__(self, parent):
            wxFrame.__init__(self, id=wxNewId(), name='AppFrame',
parent=parent,
                  pos=wxPoint(369, 254), size=wxSize(200, 300),
                  style=wxDEFAULT_FRAME_STYLE, title='Test')

            self.panel = PanelSim(self, None, None, None, None, None)
            self.mainSizer = wxBoxSizer(orient=wxVERTICAL)
            self.mainSizer.AddWindow(self.panel, 1, border=0, flag=wxGROW |
wxALL)
            self.SetSizer(self.mainSizer)
            self.SetAutoLayout(True)
        
    # run test
    app = wxPySimpleApp()
    dlg = AppFrame(None)
    dlg.Show()
    app.MainLoop()

Schoenborn, Oliver wrote:

Hello,

I have a panel for which I can't get sizers to work, and my brain is near
fried. The problem is basically that a custom panel I have made runs fine,
sizer-wise, in a self test. But when I include it in another panel, the
sizer stuff doesn't work, and I just can't figure it out.

So there are two files, one is ~80 LOC, the other 160 LOC. I include here
only the first, since second one I think too large to post (but you need the
long one to run the first).

Rather than leaving out code because it is too big it would have been better to reproduce the problem in a smaller sample app. Not only would you understand the problem better and perhaps fix it yourself, but we would be able to have something to run and perhaps be able to instantly identify the problem for you.

Just send me an email or reply and I will send
you the second file directly. If you run both files you will see clearly,
one (not attached) has things well layed out, the other (included below)
creates a panel that is partially clipped.

When adding this panel to the parent's sizer try using the wxADJUST_MINSIZE flag.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!