[wxPython] Setting Constraints on wxCompositeShape

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Setting Constraints on wxCompositeShape

Patrick Gaffney
I am trying to create a wxCompositeShape of two wxRectangleShapes. I
want these rectangles, and hopefully more, to track together and act as
one. Unfortunately, when I try to set the
constraintS(wxOGLConstraint(gyCONSTRAINT_CENTRED_BOTH, self.header,
[self.body])) for the composite shape, the program core dumps.


class TestWindow(wxShapeCanvas):
        def __init__(self, parent, frame):
                wxShapeCanvas.__init__(self, parent)

                self.frame = frame
                self.SetBackgroundColour(wxWHITE)
               
                self.diagram = wxDiagram()
                self.SetDiagram(self.diagram)
                self.diagram.SetCanvas(self)

                self.body = self.MyAddShape(wxRectangleShape(150, 100), 300, 80,
wxBLACK_PEN, wxCYAN_BRUSH, "Name")
                self.header = self.MyAddShape(wxRectangleShape(150, 30), 300, 15,
wxBLACK_PEN, wxBLUE_BRUSH, "Type")

                self.myCompositeShape = wxCompositeShape()
                self.myCompositeShape.AddChild(self.body)
                self.myCompositeShape.AddChild(self.header)
               
                myConst = wxOGLConstraint(gyCONSTRAINT_CENTRED_BOTH, self.header,
[self.body])
                self.myCompositeShape.AddConstraint(myConst)
               
                self.myCompositeShape.SetDraggable(true)
                res = self.myCompositeShape.Recompute()
               
                self.diagram.AddShape(self.myCompositeShape)
                self.myCompositeShape.Show(true)
               
                print "Recompute result '",res,"' Composite Size
'",self.myCompositeShape.CalculateSize(),"'"
               
                return
                               
               
        def MyAddShape(self, shape, x, y, pen, brush, text):
# shape.SetDraggable(true)
                shape.SetCanvas(self)
                shape.SetX(x)
                shape.SetY(y)
                shape.SetPen(pen)
                shape.SetBrush(brush)
                shape.SetFormatMode(FORMAT_CENTRE_HORIZ,0)
                shape.SetTextColour('RED', 0)
                shape.AddText(text)
                return shape
               

I'm guessing the problem centers around the third argument of
wxOGLConstraint. It asks for a wxList object. I tried a python list,
tuple or just the object itself, all with the same core dump results. I
also tried to create a wxList object but I just get a nameError. I guess
wxPython does not support wxList.

Any help or example code I could look at, would be extremely helpful.
Thanks

 
Patrick Gaffney

[hidden email]
http://www.asti-usa.com

Advanced Simulation Technology Inc.
441A Carlisle Dr.
Herndon VA 20170
(tel)703-471-2104
(fax)703-471-2108


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users