Пример #1
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(500, 300),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        self.oglcanvas = ogl.ShapeCanvas(self)
        sizer.Add(self.oglcanvas, 1, wx.GROW)

        self.oglcanvas.SetBackgroundColour("LIGHT BLUE")

        self.oglcanvas.Bind(wx.EVT_RIGHT_DOWN, self.OnRightButtonEvent)

        diagram = ogl.Diagram()
        self.oglcanvas.SetDiagram(diagram)
        diagram.SetCanvas(self.oglcanvas)

        shape = ogl.CircleShape(60.0)
        self.mycircle = shape
        shape.SetX(25.0)
        shape.SetY(25.0)
        self.oglcanvas.AddShape(shape)
        diagram.ShowAll(1)

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)

        self.Start()
Пример #2
0
    def __init__(self, canvas):
        ogl.CompositeShape.__init__(self)

        self.SetCanvas(canvas)

        constraining_shape = ogl.RectangleShape(120, 100)
        constrained_shape1 = ogl.CircleShape(50)
        constrained_shape2 = ogl.RectangleShape(80, 20)

        constraining_shape.SetBrush(wx.BLUE_BRUSH)
        constrained_shape2.SetBrush(wx.RED_BRUSH)

        self.AddChild(constraining_shape)
        self.AddChild(constrained_shape1)
        self.AddChild(constrained_shape2)

        constraint = ogl.Constraint(ogl.CONSTRAINT_MIDALIGNED_BOTTOM,
                                    constraining_shape,
                                    [constrained_shape1, constrained_shape2])
        self.AddConstraint(constraint)
        self.Recompute()

        # If we don't do this, the shapes will be able to move on their
        # own, instead of moving the composite
        constraining_shape.SetDraggable(False)
        constrained_shape1.SetDraggable(False)
        constrained_shape2.SetDraggable(False)

        # If we don't do this the shape will take all left-clicks for itself
        constraining_shape.SetSensitivityFilter(0)
Пример #3
0
    def test_lib_oglCircle(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.CircleShape(50)
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)
Пример #4
0
    def __init__(self, parent, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        self.SetBackgroundColour("LIGHT BLUE")
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)

        self.circle = ogl.CircleShape(100)
        self.circle.SetCanvas(self)
        self.circle.a = "Circle identified"
        self.diagram.AddShape(self.circle)
        self.circle.Show(True)

        if CLICK_TO_DRAG:
            self.evthandler = MyEvtHandler()
            self.evthandler.SetShape(self.circle)
            self.evthandler.SetPreviousHandler(self.circle.GetEventHandler())
            self.circle.SetEventHandler(self.evthandler)
        else:
            self.Bind(wx.EVT_MOTION, self.OnMotion, self)
Пример #5
0
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          -1,
                          "Demo",
                          size=(300, 200),
                          style=wx.DEFAULT_FRAME_STYLE)
        sizer = wx.BoxSizer(wx.VERTICAL)
        # put stuff into sizer

        canvas = ogl.ShapeCanvas(self)
        sizer.Add(canvas, 1, wx.GROW)

        canvas.SetBackgroundColour("LIGHT BLUE")  #

        diagram = ogl.Diagram()
        canvas.SetDiagram(diagram)
        diagram.SetCanvas(canvas)

        shape = ogl.CircleShape(20.0)  #
        shape.SetX(25.0)  #
        shape.SetY(25.0)  #
        canvas.AddShape(shape)  #
        diagram.ShowAll(1)  #

        # apply sizer
        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        self.Show(1)

        # test TextEntryDialog
        dlg = wx.TextEntryDialog(
            self, 'What is your favorite programming language?', 'Eh??',
            'Python')
        dlg.SetValue("Python is the best!")
        if dlg.ShowModal() == wx.ID_OK:
            print('You entered: %s\n' % dlg.GetValue())

        dlg.Destroy()
Пример #6
0
        def __init__(self, parent, frame):
                ogl.ShapeCanvas.__init__(self, parent)

                self.SetBackgroundColour("LIGHT BLUE")
                self.diagram = ogl.Diagram()
                self.SetDiagram(self.diagram)
                self.diagram.SetCanvas(self)

                self.circle = ogl.CircleShape(100)
                #self.circle.SetCanvas(self)            # not necessary !! - should adjust the wiki at http://wiki.wxpython.org/wxOGL
                self.circle.a="Circle identified"
                self.diagram.AddShape(self.circle)
                self.circle.Show(True)

                self.working = False  # ANDY

                if CLICK_TO_DRAG:
                        self.evthandler = MyEvtHandler()
                        self.evthandler.SetShape(self.circle)
                        self.evthandler.SetPreviousHandler(self.circle.GetEventHandler())
                        self.circle.SetEventHandler(self.evthandler)
                else:
                        self.Bind(wx.EVT_MOTION, self.OnMotion, self)
Пример #7
0
    def __init__(self, canvas):
        ogl.CompositeShape.__init__(self)

        self.SetCanvas(canvas)

        # create a division in the composite
        self.MakeContainer()

        # add a shape to the original division
        shape2 = ogl.RectangleShape(40, 60)
        self.GetDivisions()[0].AddChild(shape2)

        # now divide the division so we get 2
        self.GetDivisions()[0].Divide(wx.HORIZONTAL)

        # and add a shape to the second division (and move it to the
        # centre of the division)
        shape3 = ogl.CircleShape(40)
        shape3.SetBrush(wx.CYAN_BRUSH)
        self.GetDivisions()[1].AddChild(shape3)
        shape3.SetX(self.GetDivisions()[1].GetX())

        for division in self.GetDivisions():
            division.SetSensitivityFilter(0)
Пример #8
0
    def test_lib_oglCompositeShape(self):
        ogl.OGLInitialize()
        osc = ogl.ShapeCanvas(self.frame)
        self.diagram = ogl.Diagram()
        osc.SetDiagram(self.diagram)
        self.diagram.SetCanvas(osc)

        aShape = ogl.CompositeShape()
        aShape.SetCanvas(osc)
        self.diagram.AddShape(aShape)

        constraining_shape = ogl.RectangleShape(120, 100)
        constrained_shape1 = ogl.CircleShape(50)
        constrained_shape2 = ogl.RectangleShape(80, 20)

        aShape.AddChild(constraining_shape)
        aShape.AddChild(constrained_shape1)
        aShape.AddChild(constrained_shape2)

        constraint = ogl.Constraint(ogl.CONSTRAINT_MIDALIGNED_BOTTOM,
                                    constraining_shape,
                                    [constrained_shape1, constrained_shape2])
        aShape.AddConstraint(constraint)
        aShape.Recompute()
Пример #9
0
    def __init__(self, parent, log, frame):
        ogl.ShapeCanvas.__init__(self, parent)

        maxWidth  = 1000
        maxHeight = 1000
        self.SetScrollbars(20, 20, maxWidth/20, maxHeight/20)

        self.log = log
        self.frame = frame
        self.SetBackgroundColour("LIGHT BLUE") #wx.WHITE)
        self.diagram = ogl.Diagram()
        self.SetDiagram(self.diagram)
        self.diagram.SetCanvas(self)
        self.shapes = []
        self.save_gdi = []

        rRectBrush = wx.Brush("MEDIUM TURQUOISE", wx.SOLID)
        dsBrush = wx.Brush("WHEAT", wx.SOLID)

        self.MyAddShape(
            CompositeDivisionShape(self), 
            270, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division"
            )
        
        self.MyAddShape(
            CompositeShape(self), 
            100, 260, wx.BLACK_PEN, wx.RED_BRUSH, "Composite"
            )
        
        self.MyAddShape(
            ogl.CircleShape(80), 
            75, 110, wx.Pen(wx.BLUE, 3), wx.GREEN_BRUSH, "Circle"
            )
            
        self.MyAddShape(
            ogl.TextShape(120, 45), 
            160, 35, wx.GREEN_PEN, wx.LIGHT_GREY_BRUSH, "OGL is now a\npure Python lib!"
            )

        self.MyAddShape(
            ogl.RectangleShape(85, 50), 
            305, 60, wx.BLACK_PEN, wx.LIGHT_GREY_BRUSH, "Rectangle"
            )

        self.MyAddShape(
            DrawnShape(),
            500, 80, wx.BLACK_PEN, wx.BLACK_BRUSH, "DrawnShape"
            )

        ds = self.MyAddShape(
            DividedShape(140, 150, self), 
            520, 265, wx.BLACK_PEN, dsBrush, ''
            )

        self.MyAddShape(
            DiamondShape(90, 90), 
            355, 260, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon"
            )
            
        self.MyAddShape(
            RoundedRectangleShape(95, 70), 
            345, 145, wx.Pen(wx.RED, 2), rRectBrush, "Rounded Rect"
            )

        bmp = images.Test2.GetBitmap()
        mask = wx.Mask(bmp, wx.BLUE)
        bmp.SetMask(mask)
        
        s = ogl.BitmapShape()
        s.SetBitmap(bmp)
        self.MyAddShape(s, 225, 130, None, None, "Bitmap")

        #dc = wx.ClientDC(self)
        #self.PrepareDC(dc)

        for x in range(len(self.shapes)):
            fromShape = self.shapes[x]
            if x+1 == len(self.shapes):
                toShape = self.shapes[0]
            else:
                toShape = self.shapes[x+1]

            line = ogl.LineShape()
            line.SetCanvas(self)
            line.SetPen(wx.BLACK_PEN)
            line.SetBrush(wx.BLACK_BRUSH)
            line.AddArrow(ogl.ARROW_ARROW)
            line.MakeLineControlPoints(2)
            fromShape.AddLine(line, toShape)
            self.diagram.AddShape(line)
            line.Show(True)