Help: GUI wxGlade/traits linkage

Donald 'Paddy' McCarthy paddy3118 at netscape.netNOTthisBIT
Sun Oct 19 02:45:24 EDT 2003


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.






More information about the Python-list mailing list