2.8 Creating a Dialog Window - with sizers

Sizers are a great way to ensure that your GUI layout is nice and clean.  They come in especially handy when you do not know exactly how much space a control needs and/or should be allowed to use, this can be the case when you internationalize your application (I18N) or for such controls are lists or grids where you like to give as much space as possible to them (or maybe as little as practical).

Please note that the following will just explain how to use Sizers in Boa.  For more detailed information about sizers you should check the wxPython documentation and you might also find the following links interesting.

http://wiki.wxpython.org/index.cgi/UsingSizers

http://wiki.wxpython.org/index.cgi/wxDesigner_20Sizer_20Tutorial


In the previous section you already created a Dialog, now we are going to do another one but to align things we will use sizers.


    def OnMenuHelpAboutMenu(self, event):
        dlg = Dialog2.Dialog2(self)
        try:
            dlg.ShowModal()
        finally:
            dlg.Destroy()



import wx
import Dialog2

 


Sizers



Sizer - items



Designer - with images



Sizer - items



Dialog - a bit nicer



Dialog - nice


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


Run the application. Your new Dialog should look something like this.


Dialog 2 - final


Please note that the files generated during this example are also available in the directory "Examples\guide" under your Boa installation directory.