X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b53190ef7ed59cda12dca8c63b88e7bd40b67168..c58ba15f083aa287c17fe40501f0a53b16cf685a:/wxPython/demo/OGL.py?ds=sidebyside diff --git a/wxPython/demo/OGL.py b/wxPython/demo/OGL.py index 0fad400492..871e6bc9cb 100644 --- a/wxPython/demo/OGL.py +++ b/wxPython/demo/OGL.py @@ -8,6 +8,10 @@ # o Changed to use the python version of OGL # o Added TextShape, CompositeShape and CompositeShape with divisions # +# 20040830 - Pierre Hjälm +# +# o Added DrawnShape +# import wx import wx.lib.ogl as ogl @@ -16,6 +20,38 @@ import images #---------------------------------------------------------------------- +class DrawnShape(ogl.DrawnShape): + def __init__(self): + ogl.DrawnShape.__init__(self) + + self.SetDrawnBrush(wx.WHITE_BRUSH) + self.SetDrawnPen(wx.BLACK_PEN) + self.DrawArc((0, -10), (30, 0), (-30, 0)) + + self.SetDrawnPen(wx.Pen("#ff8030")) + self.DrawLine((-30, 5), (30, 5)) + + self.SetDrawnPen(wx.Pen("#00ee10")) + self.DrawRoundedRectangle((-20, 10, 40, 10), 5) + + self.SetDrawnPen(wx.Pen("#9090f0")) + self.DrawEllipse((-30, 25, 60, 20)) + + self.SetDrawnTextColour(wx.BLACK) + self.SetDrawnFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL)) + self.DrawText("DrawText", (-26, 28)) + + self.SetDrawnBrush(wx.GREEN_BRUSH) + self.DrawPolygon([(-100, 5), (-45, 30), (-35, 20), (-30, 5)]) + + self.SetDrawnPen(wx.BLACK_PEN) + self.DrawLines([(30, -45), (40, -45), (40 ,45), (30, 45)]) + + # Make sure to call CalculateSize when all drawing is done + self.CalculateSize() + +#---------------------------------------------------------------------- + class DiamondShape(ogl.PolygonShape): def __init__(self, w=0.0, h=0.0): ogl.PolygonShape.__init__(self) @@ -247,7 +283,7 @@ class TestWindow(ogl.ShapeCanvas): self.MyAddShape( CompositeDivisionShape(self), - 310, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division" + 270, 310, wx.BLACK_PEN, wx.BLUE_BRUSH, "Division" ) self.MyAddShape( @@ -270,14 +306,19 @@ class TestWindow(ogl.ShapeCanvas): 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), - 515, 145, wx.BLACK_PEN, dsBrush, '' + 520, 265, wx.BLACK_PEN, dsBrush, '' ) self.MyAddShape( DiamondShape(90, 90), - 445, 305, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon" + 355, 260, wx.Pen(wx.BLUE, 3, wx.DOT), wx.RED_BRUSH, "Polygon" ) self.MyAddShape( @@ -377,14 +418,6 @@ Pierre Hj less likely to get rusty because nobody cares about the C++ lib any more. -
The Python version should be mostly drop-in compatible with the -wrapped C++ version, except for the location of the package -(wx.lib.ogl instead of wx.ogl) and that the base class methods are -called the normal Python way (superclass.Method(self, ...)) instead of the -hacky way that had to be done to support overloaded methods with the -old SWIG (self.base_Method(...)) - - """ if __name__ == '__main__':