wx.Dialog and sizers

i'm using the following code as a test:

        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('#4f5049')
        vbox = wx.BoxSizer(wx.VERTICAL)

        midPan = wx.Panel(panel, -1)
        midPan.SetBackgroundColour('#ededed')

        vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
        panel.SetSizer(vbox)
        self.Centre()
        self.Show(True)

it works fine in my main application, but it does nothing in the
wx.Dialog that i call. what am i doing wrong?

thanks,
bob k.

ps (wxPython in Action is on the way, but i don't have it yet)

Bob,

i'm using the following code as a test:

         panel = wx.Panel(self, -1)
         panel.SetBackgroundColour('#4f5049')
         vbox = wx.BoxSizer(wx.VERTICAL)

         midPan = wx.Panel(panel, -1)
         midPan.SetBackgroundColour('#ededed')

         vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
         panel.SetSizer(vbox)
         self.Centre()
         self.Show(True)

it works fine in my main application, but it does nothing

You mean you don't see these two panels or ......?

in the
wx.Dialog that i call. what am i doing wrong?

Just pasted above code into a dialog and run it and looks fine to me. Can you attach the the file with the wx.Dialog you did.

Werner

···

On 15/01/2011 19:55, BobK wrote:

Are you doing anything to manage the size/position of the first panel? Have you added it to a sizer that is assigned to self?

I seem to recall that on one platform that a dialog doesn't get an initial size event like frames do, so that may be part of the problem as well. So you may need to do something to help force the initial layout, like calling self.SendSizeEvent or self.Layout.

···

On 1/15/11 10:55 AM, BobK wrote:

i'm using the following code as a test:

         panel = wx.Panel(self, -1)
         panel.SetBackgroundColour('#4f5049')
         vbox = wx.BoxSizer(wx.VERTICAL)

         midPan = wx.Panel(panel, -1)
         midPan.SetBackgroundColour('#ededed')

         vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
         panel.SetSizer(vbox)
         self.Centre()
         self.Show(True)

it works fine in my main application, but it does nothing in the
wx.Dialog that i call. what am i doing wrong?

--
Robin Dunn
Software Craftsman

i'm using Wingware Python IDE
Windows 7
wxPython 2.9

#!/usr/bin/python

# dialogChemicalTable.py

import wx

def create(parent):
    return DialogChemicalTable(parent)

class DialogChemicalTable(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wx.ID_ANY,
            name='DialogChemicalTable', parent=prnt, pos=wx.Point(780,
336),
            size=wx.Size(598, 411),
            style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE,
            title='Edit Chemical Table')
        self.SetClientSize(wx.Size(582, 373))

        # panels
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('#4f5049')
        vbox = wx.BoxSizer(wx.VERTICAL)

        midPan = wx.Panel(panel, -1)
        midPan.SetBackgroundColour('#ededed')

        vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
        panel.SetSizer(vbox)

        self.Center()
        self.Show(True)

    def __init__(self, parent):
        self._init_ctrls(parent)

Robin,

i've changed the code to:

        # panels
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('#4f5049')
        vbox = wx.BoxSizer(wx.VERTICAL)

        midPan = wx.Panel(panel, -1)
        midPan.SetBackgroundColour('#ededed')

        vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
        #panel.SetSizer(vbox)
        panel.SetSizerAndFit(vbox)
        panel.Layout()

the display now is visible, but it' a small portion of the wx.Dialog
(the upper left corner). in the main wx.Frame app it uses the entire
frame.

bob k.

Robin,

i've changed the code to:

        # panels
        panel = wx.Panel(self, -1)
        panel.SetBackgroundColour('#4f5049')
        vbox = wx.BoxSizer(wx.VERTICAL)

        midPan = wx.Panel(panel, -1)
        midPan.SetBackgroundColour('#ededed')

        vbox.Add(midPan, 1, wx.EXPAND | wx.ALL, 20)
        #panel.SetSizer(vbox)
        panel.SetSizerAndFit(vbox)
        panel.Layout()

the display now is visible, but it' a small portion of the wx.Dialog
(the upper left corner). in the main wx.Frame app it uses the entire
frame.

bob k.

What about the attached, i.e. add a sizer to the dialog and add the panel to that sizer and then call Layout on the dialog.

Werner

bobdialog2.py (1.28 KB)

···

On 16/01/2011 16:09, BobK wrote:

i'm using Wingware Python IDE
Windows 7
wxPython 2.9

that did it...

thank you Werner.

···

On Jan 16, 11:02 am, werner <wbru...@free.fr> wrote:

On 16/01/2011 16:09, BobK wrote:> i'm using Wingware Python IDE
> Windows 7
> wxPython 2.9

What about the attached, i.e. add a sizer to the dialog and add the
panel to that sizer and then call Layout on the dialog.

Werner

bobdialog2.py
1KViewDownload