[wxPython] wxGridSizer on Linux and Windows

On Linux Python 2.1.1 with wxPython 2.3.1-1
On Windows Python 2.1 with wxPython 2.3.2-1

I hava a problem with a dialog that uses wxGridSizer. Is there a
different startegy to layout widgets in a dialog then in a frame ?
With frame I just use SetAutoLayout() and SetSizer( aSizer) and its
done, but with Dialogs do I need something more ?

On linux everything looks just fine, but on Windows all widgets are put
in the top left corner.

I would be very thankful for any sugestions.

Thanks Przemek

Here is the dialog:

···

#----------------------------------------------------------------------
stations = [ 'TVP1', 'TVP2', 'Polsat', 'TVN' ]

class PromptDialog(wxDialog):
  title = "Edycja Promptu"
  def __init__(self, parent):
    wxDialog.__init__(self, parent, -1, self.title, size=wxSize(250,150))
    self.Centre()

    self.startTxt = wxTextCtrl( self, -1, "00:00" )
    self.endTxt = wxTextCtrl( self, -1, "" )
    self.stationCmb = wxComboBox( self, -1, "", choices = stations)

    gs = wxGridSizer(4, 2, 0, 0)
    gs.AddMany(
      [(wxStaticText( self, -1, "Poczatek"), 0, wxALIGN_CENTER | wxALL,
        10 ),
       ( self.startTxt, 0, wxALL, 10 ),
       ( wxStaticText( self, -1, "Koniec"), 0, wxALIGN_CENTER | wxALL,
           10 ),
       ( self.endTxt, 0, wxALL, 10 ),
       ( wxStaticText( self, -1, "Stacja:"), 0, wxALIGN_CENTER | wxALL,
          10 ),
       ( self.stationCmb, 0, wxALL, 10 ),
       ( wxButton(self, wxID_OK, 'OK'), 0, wxALIGN_CENTER | wxALL, 10 ),
       ( wxButton(self, wxID_CANCEL, 'Anuluj'), 0, wxALIGN_CENTER | wxALL,
         10 ),
       ])

    self.SetAutoLayout(true)
    self.SetSizer( gs )

  def OnExitButton( self, event ):
    self.Close()

--
Przemysław G. Gawroński
Informatyk - Dział Telemetrii
TNS OBOP
tel.: (0 22) 648 30 71, (0 22) 648 20 44 (-46)
fax: (0 22) 644 99 47
mailto:P.Gawronski@obop.com.pl
http://www.obop.com.pl/

Przemyslaw G. Gawronski wrote:

On Linux Python 2.1.1 with wxPython 2.3.1-1
On Windows Python 2.1 with wxPython 2.3.2-1

I hava a problem with a dialog that uses wxGridSizer. Is there a
different startegy to layout widgets in a dialog then in a frame ?
With frame I just use SetAutoLayout() and SetSizer( aSizer) and its
done, but with Dialogs do I need something more ?

On linux everything looks just fine, but on Windows all widgets are put
in the top left corner.

Add only two lines and it will work on *nix too.

mak

[snip]

    self.SetAutoLayout(true)
    self.SetSizer( gs )

      gs.Fit(self)

     gs.SetSizeHints(self)

···

  def OnExitButton( self, event ):

I hava a problem with a dialog that uses wxGridSizer. Is there a
different startegy to layout widgets in a dialog then in a frame ?
With frame I just use SetAutoLayout() and SetSizer( aSizer) and its
done, but with Dialogs do I need something more ?

On linux everything looks just fine, but on Windows all widgets are put
in the top left corner.

Call self.Layout() at the end of your dialog's __init__. The wxDialog
doesn't get an initial size event on MSW.

···

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