Hi,
I need to get the object that is represented by a selected wxShape. To
make this work I subclassed the shape:
class tsPolygonShape(wxPolygonShape):
def __init__(self,parent):
wxPolygonShape.__init__(self)
self.parent=parent
but when I try to get the parent as in:
for shape in self.diagram.GetShapeList():
if xber[0]<shape.GetX()<xber[1]:
if yber[0]<shape.GetY()<yber[1]:
shape.Select(true, dc)
selektiert.append(shape.parent)
it leads only to:
Traceback (most recent call last):
File "fem2.py", line 707, in OnEndDragLeft
selektiert.append(shape.parent)
AttributeError: wxPyShapePtr instance has no attribute 'parent'
Hi,
I need to get the object that is represented by a selected wxShape. To
make this work I subclassed the shape:
class tsPolygonShape(wxPolygonShape):
def __init__(self,parent):
wxPolygonShape.__init__(self)
self.parent=parent
but when I try to get the parent as in:
for shape in self.diagram.GetShapeList():
if xber[0]<shape.GetX()<xber[1]:
if yber[0]<shape.GetY()<yber[1]:
shape.Select(true, dc)
selektiert.append(shape.parent)
it leads only to:
Traceback (most recent call last):
File "fem2.py", line 707, in OnEndDragLeft
selektiert.append(shape.parent)
AttributeError: wxPyShapePtr instance has no attribute 'parent'
I therefore have 2 questions:
Is it feasible to subclass wxShapes at all?
It should be working since wxShape supports OOR, and wxDiagram.GetShapeList is checking for the original python object in the list it is getting back... What version are you using?
Oh, just thought of something else... If the shape is selected then the resize handles created by OGL are also wxShapes that will be returned by GetShapeList, and since they were not created in Python they will have no original object and so a new wxPyShapePtr will be created for them. Check shape.GetClassName to see what kind of C++ object it is.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Hi,
I only get "selected" shapes back, so the resize handles are not a
problem. shape.GetClassName does not work (has no attribute). I think I
will simply use SetId/GetId.
Sorry, I forgot the version last time. I am using Python2.1 with
wxPython2.2.9, which is considered "stable" by Debian woody.
The core of the problem seems to be, that I get from
self.diagram.GetShapeList() a list of wxPyShapePtr (whatever this is) but
not a list of shapes?
Sorry, but the OOR support showed up in some 2.3.x version of wxPython. There are 2.4.0.x debian packages around or you can build it yourself, check the list archives.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!