Help: GUI wxGlade/traits linkage

  • Thread starter Donald 'Paddy' McCarthy
  • Start date
D

Donald 'Paddy' McCarthy

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.
 
D

Donald 'Paddy' McCarthy

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

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top