Help: GUI wxGlade/traits linkage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Donald 'Paddy' McCarthy

    Help: GUI wxGlade/traits linkage

    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(se lf, -1)
    <<snip>>


    So with the traits example code of:

    import traits
    import traits.wxtrait_ sheet
    class Person ( traits.HasTrait s ):
    __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.TraitShee t ( 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.TraitShee t ( wxFrame, bill)
    File
    "C:\Python23_En thought\lib\sit e-packages\traits \wxtrait_sheet. py", line 3
    22, in __init__
    wx.wxPanel.__in it__( self, parent, -1 )
    File ".\site-packages\wxPyth on\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

    #2
    Re: Help: GUI wxGlade/traits linkage

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

    self.btTraits = traits.wxtrait_ sheet.TraitShee t ( self, bill)


    Donald 'Paddy' McCarthy wrote:[color=blue]
    > 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(se lf, -1)
    > <<snip>>
    >
    >
    > So with the traits example code of:
    >
    > import traits
    > import traits.wxtrait_ sheet
    > class Person ( traits.HasTrait s ):
    > __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.TraitShee t ( 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.TraitShee t ( wxFrame, bill)
    > File
    > "C:\Python23_En thought\lib\sit e-packages\traits \wxtrait_sheet. py", line 3
    > 22, in __init__
    > wx.wxPanel.__in it__( self, parent, -1 )
    > File ".\site-packages\wxPyth on\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.
    >
    >[/color]

    Comment

    Working...