[wxPython] [Q] how to create a derived class from wxRectangleShape

Hi, all...
I'd like to get some help on how to create a derived class from
wxRectangleShape. I wanted to add get/set method for the name of
wxRectangleShape object because wxRectangleShape does not have these
methods.
So I created a derived class like this.

from wxPython.ogl import wxRectangleShape
class ConceptNode( wxRectangleShape ):
    def __init__( self, w = 0.0, h = 0.0, name = 'Concept' ):
        wxRectangleShape.__init__( self, w, h )

        # self.connector: RelationLine object
        # self.name: concept node name

    def setName( self, name ):
        self.name = name

    def getName( self ):
        return self.name

Whenever I created a ConceptNode object in the main class, I set its name as
follows.
#...
self.addConceptNode( ConceptNode( nodeWidth, nodeHeight ),
                             x, y, wxBLACK_PEN,
                             wxLIGHT_GREY_BRUSH, dialog.GetValue() )
#...

    def addConceptNode(self, shape, x, y, pen, brush, text):
        #...
        shape.setName( text )
        print 'set name at addConceptNode', shape.getName()

        self.diagram.AddShape(shape)
        shape.Show(true)

        evthandler = MyEvtHandler( self.log, self.parent, self )
        #...

In the main class, I keep a list of two ConceptNode objects and they are
used in the MyEvtHandler like below code.
class MyEvtHandler(wxShapeEvtHandler):
    def __init__(self, log, frame, conceptWindow ):
        wxShapeEvtHandler.__init__(self)
        self.log = log
        self.frame = frame
        self.conceptWindow = conceptWindow # main class

    #...

def handlePositiveRelation( self, x, y, keys, attachment ):
    #...
    shape = self.GetShape() # shape should be a ConceptNode object.
    conceptWindow = self.conceptWindow

        print conceptWindow.fromToNodes

        if len( conceptWindow.fromToNodes ) == 0:
            conceptWindow.fromToNodes.append( shape )
            return
        if len( conceptWindow.fromToNodes ) == 1:
            fromNode = conceptWindow.fromToNodes[0]

        #...
        print 'check fromnode', fromNode.getName()
        #....

I got
AttributeError: wxPyRectangleShapePtr instance has no attribute 'getName' in
the last print statement.

Internally, wxPython seems to treat my ConceptNode object as a
wxPyRectangleShapePtr, but this is not what I want.
How can I access the method I created in the derived class?
Thanks in advance.

YJ

    shape = self.GetShape() # shape should be a ConceptNode object.
        #....

I got
AttributeError: wxPyRectangleShapePtr instance has no attribute 'getName'

in

the last print statement.

Internally, wxPython seems to treat my ConceptNode object as a
wxPyRectangleShapePtr, but this is not what I want.
How can I access the method I created in the derived class?

OGL also suffers from what I have called the OOR problem, (see the list
archives and the comments in the demo.) I plan on doing the work necessary
in the C++ parts of OGL that will allow me to do the same fix in the python
wrappers that I did for windows and etc. I hope to get it done before the
2.3.2 final release.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!