[wxPython] TAB functionality in FRAM

Thanks for replies.
Yes, it does work - having added the controls to the Panel instead of the Frame. However, when I had the controls on the frame, the size of the dialog was automatically set to minimum needed. I seem to have 'lost' this feature. Code (fragment) below shows how I set the sizers etc.

Could someone tell me what I'm doing wrong ?

In the demo for wxPython where I've taken this code from, one of the entries in the list supplied to AddMany is (175,50). Where can I find documentation on this ?

class LoginFrame(wxFrame):
    def __init__(self, parent, id, title, fw):
        self.Fw = fw
        # First, call the base class' __init__ method to create the frame
        wxFrame.__init__(self, parent, id, title) #, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL )
        EVT_CLOSE(self, self.OnCloseWindow)

        self.CreateStatusBar()

        panel = wxPanel(self, -1)
        gs = wxFlexGridSizer(4, 2, 10, 5) # rows, cols, hgap, vgap
        self.Dsn = wxTextCtrl(panel, -1, fw.Dsn, wxDefaultPosition, wxDefaultSize, wxTE_READONLY)
        self.User = wxTextCtrl(panel, -1, fw.UserName)
        self.Password = wxTextCtrl(panel, -1, "", wxPoint(4, 4), wxDefaultSize, wxTE_PASSWORD)

        gs.AddMany(
            [(wxStaticText(panel, -1, LU_T("Database")), 0, wxEXPAND),
             (self.Dsn, 0, wxEXPAND),
             (wxStaticText(panel, -1, LU_T("User")), 0, wxEXPAND),
             (self.User, 0, wxEXPAND),
             (wxStaticText(panel, -1, LU_T("Password")), 0, wxEXPAND),
             (self.Password, 0, wxEXPAND),
             (wxButton(panel, wxID_OK, LU_T("Ok")), 0, wxALIGN_BOTTOM | wxALIGN_LEFT),
             (wxButton(panel, wxID_CANCEL, LU_T("Cancel")), 0, wxALIGN_BOTTOM | wxALIGN_RIGHT),
            ])
        
        #gs.AddGrowableRow(0)
        #gs.AddGrowableRow(2)
        gs.AddGrowableCol(1)

        panel.SetBackgroundColour(wxLIGHT_GREY)
        panel.sizer = gs
        panel.sizer.Fit(panel)
        panel.SetAutoLayout(true)
        panel.SetSizer(gs)
        
        EVT_BUTTON(panel, wxID_OK, self.OnOk)
        EVT_BUTTON(panel, wxID_CANCEL, self.OnCancel)

        # Manually set the size

        self.SetStatusText("Enter user login name and password")
        sw = wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_X)
        sh = wxSystemSettings_GetSystemMetric(wxSYS_SCREEN_Y)
        dw = 250
        dh = 170
        self.SetSize((dw, dh))
        self.SetPosition((sw/2 - dw/2, sh/2 - dh/2))

···

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

Thanks for replies.
Yes, it does work - having added the controls to the Panel
instead of the Frame. However, when I had the controls on
the frame, the size of the dialog was automatically set to
minimum needed. I seem to have 'lost' this feature. Code
(fragment) below shows how I set the sizers etc.

Could someone tell me what I'm doing wrong ?

Once the size of the panel has been set with "panel.sizer.Fit(panel)" then you can tell the frame to size itself based on child sizes with "self.Fit()" but that has some strange defaults for margins so maybe "self.SetClientSize(panel.GetSize())" would be better.

In the demo for wxPython where I've taken this code from,
one of the entries in the list supplied to AddMany is
(175,50). Where can I find documentation on this ?

This coresponds to wxSizer.Add(175, 50) which is in the docs. It adds an empty spacer.

···

--
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