Hi!! I have a screen with a wxshapecanvas. I add a object and when I have more than one I have a line from one object to other. My problem is that when I want to dele one object, I need that the lines are deleted too , and make a new line if I have deleted a object in the middle. The problem is that when I delete the object it seens that the object its not deleted. I cant move the objects that are linked with the same line anymore. And the last one, heheh, my code for create a line in this case dont works. Someone knows what could happen. Always I have segmentation fault.
Diego
# self.shapes is a list of the shapes
def Delete(self, event=None):
for shape in self.shapes:
if shape[0].Selected():
linha = shape[0].GetLines()
if len(linha) != 0:
fromShape = linha[0].GetFrom()
if len(linha) > 1:
toShape = linha[1].GetTo()
for x in linha:
self.rightwin.diagram.RemoveShape(x)
x.Destroy()
self.rightwin.Refresh()
shape[0].Select(False)
self.rightwin.diagram.RemoveShape(shape[0])
shape[0].Destroy()
self.rightwin.Refresh()
self.shapes.remove(shape)
if len(self.shapes) > 1:
dc = wxClientDC(self)
self.rightwin.PrepareDC(dc)
line = wxLineShape()
line.SetCanvas(self.rightwin)
line.SetPen(wxBLACK_PEN)
line.SetBrush(wxBLACK_BRUSH)
line.AddArrow(ARROW_ARROW)
line.MakeLineControlPoints(2)
fromShape.AddLine(line, toShape)
self.rightwin.diagram.AddShape(line)
line.Show(True)
self.rightwin.Refresh()
fromShape.Move(dc, fromShape.GetX(), fromShape.GetY())