[wxPython] layout managers work in wxDialog?

Hi,

  I'm having trouble using a layout manager with wxDialog. If I add a panel
to a wxDialog, and then set constraints on the panel, the constraints are
never used when the dialog is displayed. I was wondering if I was doing
something wrong or if wxDialog just isn't supposed to handle window objects
with layout constraints. I've attached code below which illustrates what I'm
talking about.

Thanks,
Seth.

···

___________________________________________________________________

from wxPython.wx import *

class GUIList:

    def __init__(self, parent, ID, title, position=wxDefaultPosition):

        win = wxDialog(parent, ID, title, position, wxSize(350, 200))

        listPanel = wxPanel(win, -1)
        button = wxButton(listPanel, 12, "add", wxPoint(0,0))
        
        listPanelLC = wxLayoutConstraints()
        listPanelLC.top.SameAs(win, wxTop)
        listPanelLC.bottom.SameAs(win, wxBottom)
        listPanelLC.left.SameAs(win, wxLeft)
        listPanelLC.right.SameAs(win, wxRight)

        buttonLC = wxLayoutConstraints()
        buttonLC.centreX.SameAs(win, wxCentreX)
        buttonLC.centreY.SameAs(win, wxCentreY)
        buttonLC.height.AsIs()
        buttonLC.width.AsIs()

        listPanel.SetConstraints(listPanelLC)
        button.SetConstraints(buttonLC)
        
        val = win.ShowModal()
        if val == wxID_OK:
            print "You pressed OK"
        else:
            print "You pressed Cancel"

class App(wxApp):
    def OnInit(self):
        frame = wxFrame(NULL, -1, "")
        frame.Show(true)
        GUIList(frame, -2, "")
        self.SetTopWindow(frame)
        return true

app = App(0)
app.MainLoop()

---------------------------------------------------
My opinions are my own, I don't speak for Intel

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users

  I'm having trouble using a layout manager with wxDialog. If I add a

panel

to a wxDialog, and then set constraints on the panel, the constraints are
never used when the dialog is displayed. I was wondering if I was doing
something wrong or if wxDialog just isn't supposed to handle window

objects

with layout constraints.

First of all, you didn't call SetAutoLayout(true). Secondly, with dialogs
you don't need to have a wxPanel between it and the controls. Finally, on
MSW wxDialogs don't automatically get an extra size event after they are
created. Since auto layout happens in the default size event handler it
will never to the layout unless you force it. You can either call
self.Layout() or wait to set the size of the dialog until the end of
__init__.

Some combination of the above will fix it for you.

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users