problem with wxPanel derivation class

Discussion in 'Python' started by none, Oct 11, 2007.

  1. none

    none Guest

    wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,
    saticText, TextCtrl, and a Button.

    The resulting code works fine.

    Now the problem.
    I wish to make a separate class derrived from wxPanel that has the sized
    and controls as above. It jusst won't work


    <code id="gladeGen" class="works_ok">
    #!/usr/bin/env python
    # -*- coding: ISO-8859-1 -*-
    # generated by wxGlade 0.4cvs on Thu Oct 11 13:26:19 2007

    import wx

    class MyFrameOne(wx.Frame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrameOne.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)
    self.panel = wx.Panel(self, -1)
    self.staticbox = wx.StaticBox(self.panel, -1, "StaticBox")
    self.label = wx.StaticText(self.panel, -1, "Field Name")
    self.textBox = wx.TextCtrl(self.panel, -1, "Field Value")
    self.button = wx.Button(self.panel, -1, "Edit")

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    def __set_properties(self):
    # begin wxGlade: MyFrameOne.__set_properties
    self.SetTitle("frame_1")
    self.label.SetMinSize((-1, 15))
    # end wxGlade

    def __do_layout(self):
    # begin wxGlade: MyFrameOne.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    sizer.Add(self.label, 0, wx.ALL, 3)
    sizer.Add(self.textBox, 0, wx.ALL, 3)
    sizer.Add(self.button, 0, wx.ALL, 3)
    self.panel.SetAutoLayout(True)
    self.panel.SetSizer(sizer)
    sizer.Fit(self.panel)
    sizer.SetSizeHints(self.panel)
    sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    self.SetAutoLayout(True)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    sizer_1.SetSizeHints(self)
    self.Layout()
    # end wxGlade

    # end of class MyFrameOne

    ## modified from BoaApp
    class App(wx.App):
    def OnInit(self):
    wx.InitAllImageHandlers()
    self.main = MyFrameOne(None)
    self.main.Show()
    self.SetTopWindow(self.main)
    return True

    def main():
    application = App(0)
    application.MainLoop()

    if __name__ == '__main__':
    main()

    </code>

    <code id="modifiedFromGlade" class="fails">
    #!/usr/bin/env python
    # -*- coding: ISO-8859-1 -*-
    #The commented out code from MyFrame was moved to class Panel \
    # and appropriately modified by changing self.panel to self etc

    import wx

    class MyFrameTwo(wx.Frame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrameTwo.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)
    ## self.panel = panel(self, -1)
    self.panel = Panel(self, -1)
    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    def __set_properties(self):
    # begin wxGlade: MyFrameTwo.__set_properties
    self.SetTitle("frame_1")
    self.label.SetMinSize((-1, 15))
    # end wxGlade

    def __do_layout(self):
    # begin wxGlade: MyFrameTwo.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    ## sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    ## sizer.Add(self.label, 0, wx.ALL, 3)
    ## sizer.Add(self.textBox, 0, wx.ALL, 3)
    ## sizer.Add(self.button, 0, wx.ALL, 3)
    #### self.panel.SetAutoLayout(True)
    ## self.panel.SetSizer(sizer)
    ## sizer.Fit(self.panel)
    ## sizer.SetSizeHints(self.panel)
    sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    self.SetAutoLayout(True)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    sizer_1.SetSizeHints(self)
    self.Layout()
    # end wxGlade

    # end of class MyFrameTwo


    class Panel (wx.Panel):
    def __init__(self, *args, **kwds):
    self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    self.label = wx.StaticText(self, -1, "Field Name")
    self.textBox = wx.TextCtrl(self, -1, "Field Value")
    self.button = wx.Button(self, -1, "Edit")
    __doLayout()

    def __doLayout():
    sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    sizer.Add(self.label, 0, wx.ALL, 3)
    sizer.Add(self.textBox, 0, wx.ALL, 3)
    sizer.Add(self.button, 0, wx.ALL, 3)

    # maybe comment this and uncommennt frame2's corresponding line
    panel.SetAutoLayout(True)

    self.SetSizer(sizer)
    sizer.Fit(self.panel)
    sizer.SetSizeHints(self.panel)


    ## modified from BoaApp
    class App(wx.App):
    def OnInit(self):
    wx.InitAllImageHandlers()
    self.main = MyFrameTwo(None)
    self.main.Show()
    self.SetTopWindow(self.main)
    return True

    def main():
    application = App(0)
    application.MainLoop()

    if __name__ == '__main__':
    main()

    </code>

    <errorMessages>
    /home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py
    Traceback (most recent call last):
    File "/home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py", line 82, in ?
    main()
    File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 78, in main
    application = App(0)
    File
    "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    7473, in __init__
    self._BootstrapApp()
    File
    "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    7125, in _BootstrapApp
    return _core_.PyApp__BootstrapApp(*args, **kwargs)
    File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 72, in OnInit
    self.main = MyFrameTwo(None)
    File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 13, in __init__
    self.panel = Panel(self, -1)
    File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 48, in __init__
    self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    File
    "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_controls.py",
    line 990, in __init__
    newobj = _controls_.new_StaticBox(*args, **kwargs)
    TypeError: argument number 1: a 'wxWindow *' is expected, 'Panel' is
    received
    Script terminated.

    </errorMessages>


    It seems as though the complaint is that a 'wxWindow *' is expected,
    'Panel' is received
    However, Panel IS a wx.Panel derivative which IS a wx.Window derivative!
    Additionally, the methods in the code of Panel and MyFrameOne seem to be
    identical.
    I can't understand this. Anyone have any thoughts?

    I'm using spe as an IDE

    ~S~

    I taught myself everything I know about Python and wxPython in the lasst
    week and I still don't know everything.
    none, Oct 11, 2007
    #1
    1. Advertising

  2. none

    Larry Bates Guest

    none wrote:
    > wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,
    > saticText, TextCtrl, and a Button.
    >
    > The resulting code works fine.
    >
    > Now the problem.
    > I wish to make a separate class derrived from wxPanel that has the sized
    > and controls as above. It jusst won't work
    >
    >
    > <code id="gladeGen" class="works_ok">
    > #!/usr/bin/env python
    > # -*- coding: ISO-8859-1 -*-
    > # generated by wxGlade 0.4cvs on Thu Oct 11 13:26:19 2007
    >
    > import wx
    >
    > class MyFrameOne(wx.Frame):
    > def __init__(self, *args, **kwds):
    > # begin wxGlade: MyFrameOne.__init__
    > kwds["style"] = wx.DEFAULT_FRAME_STYLE
    > wx.Frame.__init__(self, *args, **kwds)
    > self.panel = wx.Panel(self, -1)
    > self.staticbox = wx.StaticBox(self.panel, -1, "StaticBox")
    > self.label = wx.StaticText(self.panel, -1, "Field Name")
    > self.textBox = wx.TextCtrl(self.panel, -1, "Field Value")
    > self.button = wx.Button(self.panel, -1, "Edit")
    >
    > self.__set_properties()
    > self.__do_layout()
    > # end wxGlade
    >
    > def __set_properties(self):
    > # begin wxGlade: MyFrameOne.__set_properties
    > self.SetTitle("frame_1")
    > self.label.SetMinSize((-1, 15))
    > # end wxGlade
    >
    > def __do_layout(self):
    > # begin wxGlade: MyFrameOne.__do_layout
    > sizer_1 = wx.BoxSizer(wx.VERTICAL)
    > sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > sizer.Add(self.label, 0, wx.ALL, 3)
    > sizer.Add(self.textBox, 0, wx.ALL, 3)
    > sizer.Add(self.button, 0, wx.ALL, 3)
    > self.panel.SetAutoLayout(True)
    > self.panel.SetSizer(sizer)
    > sizer.Fit(self.panel)
    > sizer.SetSizeHints(self.panel)
    > sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    > self.SetAutoLayout(True)
    > self.SetSizer(sizer_1)
    > sizer_1.Fit(self)
    > sizer_1.SetSizeHints(self)
    > self.Layout()
    > # end wxGlade
    >
    > # end of class MyFrameOne
    >
    > ## modified from BoaApp
    > class App(wx.App):
    > def OnInit(self):
    > wx.InitAllImageHandlers()
    > self.main = MyFrameOne(None)
    > self.main.Show()
    > self.SetTopWindow(self.main)
    > return True
    >
    > def main():
    > application = App(0)
    > application.MainLoop()
    >
    > if __name__ == '__main__':
    > main()
    >
    > </code>
    >
    > <code id="modifiedFromGlade" class="fails">
    > #!/usr/bin/env python
    > # -*- coding: ISO-8859-1 -*-
    > #The commented out code from MyFrame was moved to class Panel \
    > # and appropriately modified by changing self.panel to self etc
    >
    > import wx
    >
    > class MyFrameTwo(wx.Frame):
    > def __init__(self, *args, **kwds):
    > # begin wxGlade: MyFrameTwo.__init__
    > kwds["style"] = wx.DEFAULT_FRAME_STYLE
    > wx.Frame.__init__(self, *args, **kwds)
    > ## self.panel = panel(self, -1)
    > self.panel = Panel(self, -1)
    > self.__set_properties()
    > self.__do_layout()
    > # end wxGlade
    >
    > def __set_properties(self):
    > # begin wxGlade: MyFrameTwo.__set_properties
    > self.SetTitle("frame_1")
    > self.label.SetMinSize((-1, 15))
    > # end wxGlade
    >
    > def __do_layout(self):
    > # begin wxGlade: MyFrameTwo.__do_layout
    > sizer_1 = wx.BoxSizer(wx.VERTICAL)
    > ## sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > ## sizer.Add(self.label, 0, wx.ALL, 3)
    > ## sizer.Add(self.textBox, 0, wx.ALL, 3)
    > ## sizer.Add(self.button, 0, wx.ALL, 3)
    > #### self.panel.SetAutoLayout(True)
    > ## self.panel.SetSizer(sizer)
    > ## sizer.Fit(self.panel)
    > ## sizer.SetSizeHints(self.panel)
    > sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    > self.SetAutoLayout(True)
    > self.SetSizer(sizer_1)
    > sizer_1.Fit(self)
    > sizer_1.SetSizeHints(self)
    > self.Layout()
    > # end wxGlade
    >
    > # end of class MyFrameTwo
    >
    >
    > class Panel (wx.Panel):
    > def __init__(self, *args, **kwds):
    > self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    > self.label = wx.StaticText(self, -1, "Field Name")
    > self.textBox = wx.TextCtrl(self, -1, "Field Value")
    > self.button = wx.Button(self, -1, "Edit")
    > __doLayout()
    >
    > def __doLayout():
    > sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > sizer.Add(self.label, 0, wx.ALL, 3)
    > sizer.Add(self.textBox, 0, wx.ALL, 3)
    > sizer.Add(self.button, 0, wx.ALL, 3)
    >
    > # maybe comment this and uncommennt frame2's corresponding line
    > panel.SetAutoLayout(True)
    >
    > self.SetSizer(sizer)
    > sizer.Fit(self.panel)
    > sizer.SetSizeHints(self.panel)
    >
    >
    > ## modified from BoaApp
    > class App(wx.App):
    > def OnInit(self):
    > wx.InitAllImageHandlers()
    > self.main = MyFrameTwo(None)
    > self.main.Show()
    > self.SetTopWindow(self.main)
    > return True
    >
    > def main():
    > application = App(0)
    > application.MainLoop()
    >
    > if __name__ == '__main__':
    > main()
    >
    > </code>
    >
    > <errorMessages>
    > /home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py
    > Traceback (most recent call last):
    > File "/home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py", line 82, in ?
    > main()
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 78, in main
    > application = App(0)
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    > 7473, in __init__
    > self._BootstrapApp()
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    > 7125, in _BootstrapApp
    > return _core_.PyApp__BootstrapApp(*args, **kwargs)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 72, in OnInit
    > self.main = MyFrameTwo(None)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 13, in __init__
    > self.panel = Panel(self, -1)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 48, in __init__
    > self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_controls.py",
    > line 990, in __init__
    > newobj = _controls_.new_StaticBox(*args, **kwargs)
    > TypeError: argument number 1: a 'wxWindow *' is expected, 'Panel' is
    > received
    > Script terminated.
    >
    > </errorMessages>
    >
    >
    > It seems as though the complaint is that a 'wxWindow *' is expected,
    > 'Panel' is received
    > However, Panel IS a wx.Panel derivative which IS a wx.Window derivative!
    > Additionally, the methods in the code of Panel and MyFrameOne seem to be
    > identical.
    > I can't understand this. Anyone have any thoughts?
    >
    > I'm using spe as an IDE
    >
    > ~S~
    >
    > I taught myself everything I know about Python and wxPython in the lasst
    > week and I still don't know everything.
    >
    >

    You will probably get better results if you post this to
    gmane.com.python.wxpython list as it is specific to wxPython.

    -Larry
    Larry Bates, Oct 11, 2007
    #2
    1. Advertising

  3. none

    Guest

    You've got calls for properties in other classes and you don't
    initialize the panel object. I edited the code somewhat so it'll at
    least run. I tried to comment where I changed things, but I may have
    missed a few minor points. See below:

    <code>

    #The commented out code from MyFrame was moved to class Panel \
    # and appropriately modified by changing self.panel to self etc

    import wx

    class MyFrameTwo(wx.Frame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrameTwo.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)
    ## self.panel = panel(self, -1)
    self.panel = Panel(self, -1)
    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    def __set_properties(self):
    # begin wxGlade: MyFrameTwo.__set_properties
    self.SetTitle("frame_1")
    # end wxGlade

    def __do_layout(self):
    # begin wxGlade: MyFrameTwo.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    self.SetAutoLayout(True)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    sizer_1.SetSizeHints(self)
    self.Layout()
    # end wxGlade

    # end of class MyFrameTwo

    class Panel (wx.Panel):
    def __init__(self, parent, *args, **kwds):
    wx.Panel.__init__(self, parent) # Added line
    self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    self.label = wx.StaticText(self, -1, "Field Name")
    self.textBox = wx.TextCtrl(self, -1, "Field Value")
    self.button = wx.Button(self, -1, "Edit")
    self.__doLayout() # added self

    def __doLayout(self): # added argument
    sizer = wx.StaticBoxSizer(self.staticbox,
    wx.HORIZONTAL)
    sizer.Add(self.label, 0, wx.ALL, 3)
    sizer.Add(self.textBox, 0, wx.ALL, 3)
    sizer.Add(self.button, 0, wx.ALL, 3)
    self.label.SetMinSize((-1, 15)) # moved from Frame

    # maybe comment this and uncommennt frame2's
    corresponding line
    self.SetAutoLayout(True)

    self.SetSizer(sizer)
    sizer.Fit(self)
    sizer.SetSizeHints(self)

    ## modified from BoaApp
    class App(wx.App):
    def OnInit(self):
    wx.InitAllImageHandlers()
    self.main = MyFrameTwo(None)
    self.main.Show()
    self.SetTopWindow(self.main)
    return True

    def main():
    application = App(0)
    application.MainLoop()

    if __name__ == '__main__':
    main()


    </code>

    Larry is correct. You'll get better help from the wxPython group. See
    http://wxpython.org/maillist.php

    Mike
    , Oct 11, 2007
    #3
  4. none

    Chris Mellon Guest

    On 10/11/07, <"@bag.python.org <"none> wrote:
    > wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,
    > saticText, TextCtrl, and a Button.
    >

    <snip>

    > It seems as though the complaint is that a 'wxWindow *' is expected,
    > 'Panel' is received
    > However, Panel IS a wx.Panel derivative which IS a wx.Window derivative!
    > Additionally, the methods in the code of Panel and MyFrameOne seem to be
    > identical.
    > I can't understand this. Anyone have any thoughts?
    >


    It's because you didn't call the base class __init__. wxPython is a
    SWIG wrapper around the C++ wxWidgets library, and if you don't call
    the base class the SWIG infrastructure that maps your class to an
    underlying C++ class doesn't happen and you get this error.
    Chris Mellon, Oct 11, 2007
    #4
  5. none

    Guest

    On Oct 11, 4:01 pm, "Chris Mellon" <> wrote:
    > On 10/11/07, <"@bag.python.org <"none> wrote:> wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,
    > > saticText, TextCtrl, and a Button.

    >
    > <snip>
    >
    > > It seems as though the complaint is that a 'wxWindow *' is expected,
    > > 'Panel' is received
    > > However, Panel IS a wx.Panel derivative which IS a wx.Window derivative!
    > > Additionally, the methods in the code of Panel and MyFrameOne seem to be
    > > identical.
    > > I can't understand this. Anyone have any thoughts?

    >
    > It's because you didn't call the base class __init__. wxPython is a
    > SWIG wrapper around the C++ wxWidgets library, and if you don't call
    > the base class the SWIG infrastructure that maps your class to an
    > underlying C++ class doesn't happen and you get this error.


    Ah-so. I knew there was a more technical answer than what I gave.
    Hopefully I didn't muddy the issue with my doofy code.

    Mike
    , Oct 12, 2007
    #5
  6. none

    none Guest

    Re: problem with wxPanel derivation class ~ thanks

    none wrote:
    > wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,
    > saticText, TextCtrl, and a Button.
    >
    > The resulting code works fine.
    >
    > Now the problem.
    > I wish to make a separate class derrived from wxPanel that has the sized
    > and controls as above. It jusst won't work
    >
    >
    > <code id="gladeGen" class="works_ok">
    > #!/usr/bin/env python
    > # -*- coding: ISO-8859-1 -*-
    > # generated by wxGlade 0.4cvs on Thu Oct 11 13:26:19 2007
    >
    > import wx
    >
    > class MyFrameOne(wx.Frame):
    > def __init__(self, *args, **kwds):
    > # begin wxGlade: MyFrameOne.__init__
    > kwds["style"] = wx.DEFAULT_FRAME_STYLE
    > wx.Frame.__init__(self, *args, **kwds)
    > self.panel = wx.Panel(self, -1)
    > self.staticbox = wx.StaticBox(self.panel, -1, "StaticBox")
    > self.label = wx.StaticText(self.panel, -1, "Field Name")
    > self.textBox = wx.TextCtrl(self.panel, -1, "Field Value")
    > self.button = wx.Button(self.panel, -1, "Edit")
    >
    > self.__set_properties()
    > self.__do_layout()
    > # end wxGlade
    >
    > def __set_properties(self):
    > # begin wxGlade: MyFrameOne.__set_properties
    > self.SetTitle("frame_1")
    > self.label.SetMinSize((-1, 15))
    > # end wxGlade
    >
    > def __do_layout(self):
    > # begin wxGlade: MyFrameOne.__do_layout
    > sizer_1 = wx.BoxSizer(wx.VERTICAL)
    > sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > sizer.Add(self.label, 0, wx.ALL, 3)
    > sizer.Add(self.textBox, 0, wx.ALL, 3)
    > sizer.Add(self.button, 0, wx.ALL, 3)
    > self.panel.SetAutoLayout(True)
    > self.panel.SetSizer(sizer)
    > sizer.Fit(self.panel)
    > sizer.SetSizeHints(self.panel)
    > sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    > self.SetAutoLayout(True)
    > self.SetSizer(sizer_1)
    > sizer_1.Fit(self)
    > sizer_1.SetSizeHints(self)
    > self.Layout()
    > # end wxGlade
    >
    > # end of class MyFrameOne
    >
    > ## modified from BoaApp
    > class App(wx.App):
    > def OnInit(self):
    > wx.InitAllImageHandlers()
    > self.main = MyFrameOne(None)
    > self.main.Show()
    > self.SetTopWindow(self.main)
    > return True
    >
    > def main():
    > application = App(0)
    > application.MainLoop()
    >
    > if __name__ == '__main__':
    > main()
    >
    > </code>
    >
    > <code id="modifiedFromGlade" class="fails">
    > #!/usr/bin/env python
    > # -*- coding: ISO-8859-1 -*-
    > #The commented out code from MyFrame was moved to class Panel \
    > # and appropriately modified by changing self.panel to self etc
    >
    > import wx
    >
    > class MyFrameTwo(wx.Frame):
    > def __init__(self, *args, **kwds):
    > # begin wxGlade: MyFrameTwo.__init__
    > kwds["style"] = wx.DEFAULT_FRAME_STYLE
    > wx.Frame.__init__(self, *args, **kwds)
    > ## self.panel = panel(self, -1)
    > self.panel = Panel(self, -1)
    > self.__set_properties()
    > self.__do_layout()
    > # end wxGlade
    >
    > def __set_properties(self):
    > # begin wxGlade: MyFrameTwo.__set_properties
    > self.SetTitle("frame_1")
    > self.label.SetMinSize((-1, 15))
    > # end wxGlade
    >
    > def __do_layout(self):
    > # begin wxGlade: MyFrameTwo.__do_layout
    > sizer_1 = wx.BoxSizer(wx.VERTICAL)
    > ## sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > ## sizer.Add(self.label, 0, wx.ALL, 3)
    > ## sizer.Add(self.textBox, 0, wx.ALL, 3)
    > ## sizer.Add(self.button, 0, wx.ALL, 3)
    > #### self.panel.SetAutoLayout(True)
    > ## self.panel.SetSizer(sizer)
    > ## sizer.Fit(self.panel)
    > ## sizer.SetSizeHints(self.panel)
    > sizer_1.Add(self.panel, 1, wx.EXPAND, 0)
    > self.SetAutoLayout(True)
    > self.SetSizer(sizer_1)
    > sizer_1.Fit(self)
    > sizer_1.SetSizeHints(self)
    > self.Layout()
    > # end wxGlade
    >
    > # end of class MyFrameTwo
    >
    >
    > class Panel (wx.Panel):
    > def __init__(self, *args, **kwds):
    > self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    > self.label = wx.StaticText(self, -1, "Field Name")
    > self.textBox = wx.TextCtrl(self, -1, "Field Value")
    > self.button = wx.Button(self, -1, "Edit")
    > __doLayout()
    >
    > def __doLayout():
    > sizer = wx.StaticBoxSizer(self.staticbox, wx.HORIZONTAL)
    > sizer.Add(self.label, 0, wx.ALL, 3)
    > sizer.Add(self.textBox, 0, wx.ALL, 3)
    > sizer.Add(self.button, 0, wx.ALL, 3)
    >
    > # maybe comment this and uncommennt frame2's corresponding line
    > panel.SetAutoLayout(True)
    >
    > self.SetSizer(sizer)
    > sizer.Fit(self.panel)
    > sizer.SetSizeHints(self.panel)
    >
    >
    > ## modified from BoaApp
    > class App(wx.App):
    > def OnInit(self):
    > wx.InitAllImageHandlers()
    > self.main = MyFrameTwo(None)
    > self.main.Show()
    > self.SetTopWindow(self.main)
    > return True
    >
    > def main():
    > application = App(0)
    > application.MainLoop()
    >
    > if __name__ == '__main__':
    > main()
    >
    > </code>
    >
    > <errorMessages>
    > /home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py
    > Traceback (most recent call last):
    > File "/home/xaos/xpy/cnc/i2g/prefDialog/test/frame2.py", line 82, in ?
    > main()
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 78, in main
    > application = App(0)
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    > 7473, in __init__
    > self._BootstrapApp()
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line
    > 7125, in _BootstrapApp
    > return _core_.PyApp__BootstrapApp(*args, **kwargs)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 72, in OnInit
    > self.main = MyFrameTwo(None)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 13, in __init__
    > self.panel = Panel(self, -1)
    > File "~/xpy/cnc/i2g/prefDialog/test/frame2.py", line 48, in __init__
    > self.staticbox = wx.StaticBox(self, -1, "StaticBox")
    > File
    > "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_controls.py",
    > line 990, in __init__
    > newobj = _controls_.new_StaticBox(*args, **kwargs)
    > TypeError: argument number 1: a 'wxWindow *' is expected, 'Panel' is
    > received
    > Script terminated.
    >
    > </errorMessages>
    >
    >
    > It seems as though the complaint is that a 'wxWindow *' is expected,
    > 'Panel' is received
    > However, Panel IS a wx.Panel derivative which IS a wx.Window derivative!
    > Additionally, the methods in the code of Panel and MyFrameOne seem to be
    > identical.
    > I can't understand this. Anyone have any thoughts?
    >
    > I'm using spe as an IDE
    >
    > ~S~
    >
    > I taught myself everything I know about Python and wxPython in the lasst
    > week and I still don't know everything.
    >
    >



    Thanks All,
    I didn't make the super() call (java terminology)
    to the base class.

    this is the only python group (en) on giganews, my first search
    no wx or qt.
    gmane.com.python.wxpython is not found
    gmane.org came up and crashed firefox 3 times searching for python.
    I'll try the wxpython forrum for x stuff, but you spoiled me with prompt
    and accurate responses.


    ~S~

    I'm trying to think, but nothing's happening
    Slowly I learn, Step by Step ...
    none, Oct 12, 2007
    #6
  7. none

    Chris Mellon Guest

    Re: problem with wxPanel derivation class ~ thanks

    On 10/12/07, <"@bag.python.org <"none> wrote:
    > none wrote:
    > > wxGlade created a simple Frame with a panel a sizer and 3 wxControls ,


    <snip>

    > Thanks All,
    > I didn't make the super() call (java terminology)
    > to the base class.
    >
    > this is the only python group (en) on giganews, my first search
    > no wx or qt.
    > gmane.com.python.wxpython is not found
    > gmane.org came up and crashed firefox 3 times searching for python.
    > I'll try the wxpython forrum for x stuff, but you spoiled me with prompt
    > and accurate responses.
    >



    The wxpython mailing list is wxpython-users. You can subscribe at
    wxPython.org. It's not mirrored to an actual newsgroup, although I'm
    sure gmane has it. You'll find wxpython-users to be at least as prompt
    and accurate, at least with regard to wxPython-specific questions.
    Chris Mellon, Oct 12, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven T. Hatton
    Replies:
    12
    Views:
    1,682
    Jonathan Turkanis
    Aug 20, 2004
  2. Piet
    Replies:
    1
    Views:
    583
  3. Replies:
    1
    Views:
    575
  4. CYBER
    Replies:
    2
    Views:
    665
    Ed Leafe
    May 3, 2005
  5. Sam
    Replies:
    3
    Views:
    642
Loading...

Share This Page