== Introduction ==
This is an example of using a Tabbed ({{{wxNotebook}}}) Dialog '''with resizable controls'''. <<BR>> (It took me more than 2 days to realize I had to use {{{wxPanel}}} instead of {{{wxWindows}}} controls) <<BR>><<BR>> Hope it helps someone... <<BR>> -- '''jbalague''' <<BR>><<BR>> See also: UsingSizers <<BR>>

== Code Sample ==
{{{#!python
import wx

#----------------------------------------------------------------------
class MyTabbedDlg(wx.Dialog):
    def __init__(self, parent):
        title = "Resize the dialog and see how controls adapt!"
        wx.Dialog.__init__(self, parent, -1, title,
                           style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)

        notebook = wx.Notebook(self, -1, size=(450,300))
        panel1 = wx.Panel(notebook)
        panel2 = wx.Panel(notebook)
        notebook.AddPage(panel1, "Panel 1")
        notebook.AddPage(panel2, "Panel 2")

        dialog_sizer = wx.BoxSizer(wx.VERTICAL)
        dialog_sizer.Add(notebook, 1, wx.EXPAND|wx.ALL, 5)

        panel1_sizer = wx.BoxSizer(wx.VERTICAL)
        text = wx.TextCtrl(panel1, -1, "Hi!", size=(400,90), style=wx.TE_MULTILINE)
        button1 = wx.Button(panel1, -1, "I only resize horizontally...")
        panel1_sizer.Add(text, 1, wx.EXPAND|wx.ALL, 10)
        panel1_sizer.Add(button1, 0, wx.EXPAND|wx.ALL, 10)
        panel1.SetSizer(panel1_sizer)

        panel2_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button2 = wx.Button(panel2, -1, "I resize vertically")
        button3 = wx.Button(panel2, -1, "I don't like resizing!")
        panel2_sizer.Add(button2, 0, wx.EXPAND|wx.ALL, 20)
        panel2_sizer.Add(button3, 0, wx.ALL, 100)
        panel2.SetSizer(panel2_sizer)

        if "__WXMAC__" in wx.PlatformInfo:
           self.SetSizer(dialog_sizer)
        else:
           self.SetSizerAndFit(dialog_sizer)
        self.Centre()

        self.Bind(wx.EVT_BUTTON, self.OnButton)


    def OnButton(self, evt):
        self.EndModal(0)


#----------------------------------------------------------------------
class MyApp(wx.App):
    def OnInit(self):
        dlg = MyTabbedDlg(None)
        dlg.ShowModal()
        dlg.Destroy()
        return True

myapp = MyApp(redirect=False)
myapp.MainLoop()
}}}
== Comments ==
<<BR>>

I like the example, but it would be better if it were possible to get it to stop running. Since the dialog appears to have no way to quit, and it's modal, the controlling application can't be terminated. Or is this only a problem on Windows?

It works better if the dialog style is set to wxRESIZE_BORDER+wxDEFAULT_DIALOG_STYLE, then the dialog can be closed in a controlled way. ''SteveHolden''

 .
----
This example crashes with a Bus error (core dump) on MacOSX 10.3, wxPython 2.5.3.1. It only works if you add the wxDEFAULT_DIALOG_STYLE as mentioned above. Here is the trace...maybe some smart individual will see this and fix the source code to window.cpp...

{{{
0   libwx_macu-2.5.3.dylib      0x027b4ec4 wxWindow::MacSetBackgroundBrush(wxBrush const&) + 0x40
1   libwx_macu-2.5.3.dylib      0x027b4e2c wxWindow::SetBackgroundColour(wxColour const&) + 0x128
2   libwx_macu-2.5.3.dylib      0x027b126c wxTopLevelWindowMac::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&) + 0xdc
3   libwx_macu-2.5.3.dylib      0x027865f4 wxDialog::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxString const&) + 0x6c
4   _windows_.so                0x02e0c590 _wrap_new_Dialog + 0x480 (dialog.h:57)
}}}
In addition, the demo has all sorts of refresh/paint issues once you get it running. Especially when you click on Panel 2.

 .
----
On OSX, if you remove wx.EXPAND from:

{{{
         panel2_sizer.Add(button2, 0, wx.EXPAND|wx.ALL, 20)
}}}
Then, the text for the button appears in the right place instead of appearing as though it is floating in the middle of the window.

----
When I run the example on my pc, the layout is not so good ,I do not see the button at "panel1" until I resizer by drag the frame, in addition, the two buttones are '''overlapping'''.the images is {{attachment:C:\Documents and Settings\Jacky\My Documents\My Pictures\bug_1.jpg}}
 the problem is resolved after what I put the parts

{{{
        notebook.AddPage(panel1, "Panel 1")
        notebook.AddPage(panel2, "Panel 2")
}}}
behind the

{{{
        panel1_sizer = wx.BoxSizer(wx.VERTICAL)
        text = wx.TextCtrl(panel1, -1, "Hi!", size=(400,90), style=wx.TE_MULTILINE)
        button1 = wx.Button(panel1, -1, "I only resize horizontally...")
        panel1_sizer.Add(text, 1, wx.EXPAND|wx.ALL, 10)
        panel1_sizer.Add(button1, 0, wx.EXPAND|wx.ALL, 10)
        panel1.SetSizer(panel1_sizer)

        panel2_sizer = wx.BoxSizer(wx.HORIZONTAL)
        button2 = wx.Button(panel2, -1, "I resize vertically")
        button3 = wx.Button(panel2, -1, "I don't like resizing!")
        panel2_sizer.Add(button2, 0, wx.EXPAND|wx.ALL, 20)
        panel2_sizer.Add(button3, 0, wx.ALL, 100)
        panel2.SetSizer(panel2_sizer)

        notebook.AddPage(panel1, "Panel 1")
        notebook.AddPage(panel2, "Panel 2")
}}}