Help: GUI wxGlade/traits linkage

Discussion in 'Python' started by Donald 'Paddy' McCarthy, Oct 19, 2003.

  1. Hi,
    I am having a few problems with a GUI. I am new to traits and wxGlade.
    I have used wxGlade to create a Form with an embedded space for a
    CustomWidget.

    I have the traits demo and would like to edit the traits and have the
    traits form appear instead of the space left for my CustomWidget.

    wxGlade produces code with the following hook (last line):

    class MyFrame(wxFrame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrame.__init__
    kwds["style"] = wxDEFAULT_FRAME_STYLE
    wxFrame.__init__(self, *args, **kwds)
    self.btTraits = CustomWidget(self, -1)
    <<snip>>


    So with the traits example code of:

    import traits
    import traits.wxtrait_sheet
    class Person ( traits.HasTraits ):
    __traits__ = {
    'name': '',
    'age': 9,
    'weight': 0.0
    }
    bill = Person()


    From reading the traits doc I thought that I would just need to change
    the call to CustomWidget above to:
    self.btTraits = traits.wxtrait_sheet.TraitSheet ( wxFrame, bill)

    But that leads to the following error:

    $ pythone btF.py
    Traceback (most recent call last):
    File "btF.py", line 84, in ?
    frame_1 = MyFrame(None, -1, "")
    File "btF.py", line 29, in __init__
    self.btTraits = traits.wxtrait_sheet.TraitSheet ( wxFrame, bill)
    File
    "C:\Python23_Enthought\lib\site-packages\traits\wxtrait_sheet.py", line 3
    22, in __init__
    wx.wxPanel.__init__( self, parent, -1 )
    File ".\site-packages\wxPython\windows.py", line 696, in __init__
    TypeError: Type error in argument 1 of new_wxPanel. Expected _wxWindow_p.



    I would be grateful for a little help.

    Thanks, Paddy.
    Donald 'Paddy' McCarthy, Oct 19, 2003
    #1
    1. Advertising

  2. I found it!
    It seems that the following line made the connection:

    self.btTraits = traits.wxtrait_sheet.TraitSheet ( self, bill)


    Donald 'Paddy' McCarthy wrote:
    > Hi,
    > I am having a few problems with a GUI. I am new to traits and wxGlade.
    > I have used wxGlade to create a Form with an embedded space for a
    > CustomWidget.
    >
    > I have the traits demo and would like to edit the traits and have the
    > traits form appear instead of the space left for my CustomWidget.
    >
    > wxGlade produces code with the following hook (last line):
    >
    > class MyFrame(wxFrame):
    > def __init__(self, *args, **kwds):
    > # begin wxGlade: MyFrame.__init__
    > kwds["style"] = wxDEFAULT_FRAME_STYLE
    > wxFrame.__init__(self, *args, **kwds)
    > self.btTraits = CustomWidget(self, -1)
    > <<snip>>
    >
    >
    > So with the traits example code of:
    >
    > import traits
    > import traits.wxtrait_sheet
    > class Person ( traits.HasTraits ):
    > __traits__ = {
    > 'name': '',
    > 'age': 9,
    > 'weight': 0.0
    > }
    > bill = Person()
    >
    >
    > From reading the traits doc I thought that I would just need to change
    > the call to CustomWidget above to:
    > self.btTraits = traits.wxtrait_sheet.TraitSheet ( wxFrame, bill)
    >
    > But that leads to the following error:
    >
    > $ pythone btF.py
    > Traceback (most recent call last):
    > File "btF.py", line 84, in ?
    > frame_1 = MyFrame(None, -1, "")
    > File "btF.py", line 29, in __init__
    > self.btTraits = traits.wxtrait_sheet.TraitSheet ( wxFrame, bill)
    > File
    > "C:\Python23_Enthought\lib\site-packages\traits\wxtrait_sheet.py", line 3
    > 22, in __init__
    > wx.wxPanel.__init__( self, parent, -1 )
    > File ".\site-packages\wxPython\windows.py", line 696, in __init__
    > TypeError: Type error in argument 1 of new_wxPanel. Expected _wxWindow_p.
    >
    >
    >
    > I would be grateful for a little help.
    >
    > Thanks, Paddy.
    >
    >
    Donald 'Paddy' McCarthy, Oct 19, 2003
    #2
    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. Pilu

    wxGlade

    Pilu, Feb 19, 2004, in forum: Python
    Replies:
    2
    Views:
    540
    Brian Kelley
    Feb 20, 2004
  2. Ben Finney

    wxGlade not Running !

    Ben Finney, Mar 2, 2004, in forum: Python
    Replies:
    1
    Views:
    327
    Somesh Bartakkay
    Mar 2, 2004
  3. Replies:
    7
    Views:
    1,142
  4. Replies:
    1
    Views:
    589
    Michael DOUBEZ
    Sep 12, 2008
  5. ray
    Replies:
    1
    Views:
    1,313
    Robert Kern
    Jun 4, 2010
Loading...

Share This Page