Resizable Tabbed (wxNotebook) Dialog

Robert Amesz sheershion at mailexpire.com
Sat Aug 17 17:20:27 CEST 2002


Jose M. Balaguer wrote:

> This is an example of using a Tabbed (wxNotebook) Dialog with
> resizable controls. (It took me more than 2 days to realize I had
> to use wxPanel instead of wxWindows controls)

Two days... That seems a bit long. Didn't you study the demo? Anyway, 
just a couple comments:


1 - If you want a normal-looking dialog, you'd better replace:
   wxDialog.__init__(self, parent, -1, title, style=wxRESIZE_BORDER)

by:

   wxDialog.__init__(self, parent, -1, title,
      style=wxRESIZE_BORDER|wxCAPTION|wxSYSTEM_MENU)


2 - Although it probably doen't make a great deal of difference here as 
it's the only window in the sizer, generally it is better to for a 
wxNotebookCtrl to be managed by a wxNotebookSizer. Things like Fit() or 
SetSizeHints() should work better that way.

In this example, because the sizer has just the one child, it is 
sufficient to replace:

   dialog_sizer = wxBoxSizer(wxVERTICAL)
   dialog_sizer.Add(notebook, 1, wxEXPAND|wxALL, 5)

by:

   dialog_sizer = wxNotebookSizer(notebook)

but in general, the wxNotebookSizer would be an additional sizer: 
instead of adding the notebook control directly to some sizer, you'd 
add the wxNotebookSizer.

Personally, I'd say that the fact than you need a special kind of sizer 
for notebooks would indicate that the interface between windows and 
sizers isn't quite optimal[*]. Still, overall it works well.


Robert Amesz
-- 
[*] Perhaps there should something like a 'resizable' base class, which 
both wxSizers and wxWindows should derive from?



More information about the Python-list mailing list