wxLineShape straight line

Thomas Aanensen wrote:

Trying to do a simple thing as drawing a straight line from one place to an
other on a canvas (not between shapes). I use the command:
line.SetEnds(100,100,200,200), but python crashes when I include this
sentence!

Am I doing it wrong?

I don't know. Please provide a small sample.

···

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

I don't know. Please provide a small sample.

Ok. I've made a small code sample and the same thing happens:

from wxPython.wx import *
from wxPython.ogl import *

wxOGLInitialize()

class Canvas(wxShapeCanvas):
    def __init__(self, parent):
        wxShapeCanvas.__init__(self, parent)

        self.diagram = wxDiagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)

        line = wxLineShape()
        line.SetCanvas(self)
        line.SetPen(wxBLACK_PEN)
        line.SetBrush(wxBLACK_BRUSH)
        line.SetEnds(10,10,200,200)
        self.diagram.AddShape(line)
        line.Show(True)

class TestApp(wxApp):
    def OnInit(self):
        frame = wxFrame(None, -1, "Test App")
        self.SetTopWindow(frame)
        canvas = Canvas(frame)
        frame.Show(1)
        return 1

if __name__ == "__main__":
    app = TestApp()
    app.MainLoop()

If i remove the lines:
        line.SetEnds(10,10,200,200)
        self.diagram.AddShape(line)

...it doesn't crash, but I still don't have my line

Thomas

Thomas Aanensen wrote:

I don't know. Please provide a small sample.

Ok. I've made a small code sample and the same thing happens:

Stupid OGL does not create control points for the line endings automatically, so you have to do it yourself by calling

         line.MakeLineControlPoints(2)

···

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