Basic drawing (Phoenix)

Keywords : Drawing, PaintDC, GCDC, Graphics context.


Demonstrating :

Tested py3.x, wx4.x and Win10.

Are you ready to use some samples ? ;)

Test, modify, correct, complete, improve and share your discoveries ! (!)


Sample one

img_sample_one.png

   1 # sample_one.py
   2 
   3 import wx
   4 
   5 # class MyPanel
   6 # class MyFrame
   7 # class MyApp
   8 
   9 #---------------------------------------------------------------------------
  10 
  11 class MyPanel(wx.Panel):
  12     def __init__(self, *args, **kwargs):
  13         wx.Panel.__init__(self, *args, **kwargs)
  14 
  15         self.Bind(wx.EVT_PAINT, self.OnPaint)
  16 
  17     #-----------------------------------------------------------------------
  18 
  19     def OnPaint(self, event):
  20         """
  21         ...
  22         """
  23 
  24         pdc = wx.PaintDC(self)
  25         gc = wx.GCDC(pdc)
  26         gc.Clear()
  27 
  28         #------------
  29         # Square.
  30         #------------
  31 
  32         gc.SetPen(wx.Pen("red", 2))
  33         gc.SetBrush(wx.Brush("yellow"))
  34 
  35         x = 100
  36         y = 30
  37         w = 50
  38         h = 50
  39 
  40         # pt, sz
  41         # or
  42         # rect
  43         # or
  44         # x, y, width, height
  45         gc.DrawRectangle(x , y, w, h)
  46         gc.DrawText("Square", int(x+w+10), int(y+h/2))
  47 
  48         #------------
  49         # Rectangle.
  50         #------------
  51 
  52         gc.SetPen(wx.Pen("black", 2))
  53         gc.SetBrush(wx.Brush((0, 255, 255, 255)))
  54 
  55         x = 100
  56         y = 130
  57         w = 100
  58         h = 50
  59 
  60         # pt, sz
  61         # or
  62         # rect
  63         # or
  64         # x, y, width, height
  65         gc.DrawRectangle(x , y, w, h)
  66         gc.DrawText("Rectangle", int(x+w+10), int(y+h/2))
  67 
  68         #------------
  69         # Rounded rectangle.
  70         #------------
  71 
  72         gc.SetPen(wx.Pen("black", 2))
  73         gc.SetBrush(wx.Brush((255, 0, 255, 128)))
  74 
  75         x = 100
  76         y = 230
  77         w = 100
  78         h = 50
  79         r = 8
  80 
  81         # pt, sz, radius
  82         # or
  83         # rect, radius
  84         # or
  85         # x, y, width, height, radius)
  86         gc.DrawRoundedRectangle(x, y, w, h, r)
  87         gc.DrawText("Rounded rectangle", int(x+w+10), int(y+h/2))
  88 
  89         #------------
  90         # Ellipse.
  91         #------------
  92 
  93         gc.SetPen(wx.Pen("gray", 2))
  94         gc.SetBrush(wx.Brush("green"))
  95 
  96         x = 100
  97         y = 330
  98         w = 100
  99         h = 50
 100 
 101         # pt, size
 102         # or
 103         # rect
 104         # or
 105         # x, y, width, height
 106         gc.DrawEllipse(x, y, w, h)
 107         gc.DrawText("Ellipse", int(x+w+10), int(y+h/2))
 108 
 109         #------------
 110         # Circle.
 111         #------------
 112 
 113         gc.SetPen(wx.Pen("red", 2))
 114         gc.SetBrush(wx.Brush("#ffc0cb"))
 115 
 116         x = 130
 117         y = 455
 118         r = 35
 119 
 120         # pt, radius
 121         # or
 122         # x, y, radius
 123         gc.DrawCircle(x, y, r)
 124         gc.DrawText("Circle", int(x+45), int(y))
 125 
 126         #------------
 127         # Line.
 128         #------------
 129 
 130         gc.SetPen(wx.Pen("purple", 4))
 131 
 132         x1 = 100
 133         y1 = 545
 134         x2 = 200
 135         y2 = 545
 136 
 137         # pt1, pt2
 138         # or
 139         # x1, y1, x2, y2
 140         gc.DrawLine(x1, y1, x2, y2)
 141         gc.DrawText("Line", int(x+w-10), int(y+80))
 142 
 143         #------------
 144         # Triangle.
 145         #------------
 146 
 147         gc.SetPen(wx.Pen("blue", 2))
 148         gc.SetBrush(wx.Brush((150, 150, 150, 128)))
 149 
 150         points = [(80, 80),
 151                   (10, 10),
 152                   (80, 10),
 153                   (80, 80)
 154                   ]
 155         x = 90
 156         y = 580
 157 
 158         # points, xoffset=0, yoffset=0, fill_style=ODDEVEN_RULE
 159         gc.DrawPolygon(points, x, y)
 160         gc.DrawText("Triangle", int(x+w-5), int(y+h/2))
 161 
 162 #---------------------------------------------------------------------------
 163 
 164 class MyFrame(wx.Frame):
 165     def __init__(self, *args, **kwargs):
 166         wx.Frame.__init__(self, *args, **kwargs)
 167 
 168         #------------
 169 
 170         frameicon = wx.Icon("icon_wxWidgets.ico")
 171         self.SetIcon(frameicon)
 172 
 173         #------------
 174 
 175         self.Panel = MyPanel(self)
 176 
 177 #---------------------------------------------------------------------------
 178 
 179 
 180 class MyApp(wx.App):
 181     """
 182     ...
 183     """
 184     def OnInit(self):
 185 
 186         #------------
 187 
 188         frame = MyFrame(None, title="Sample_one", size=(380, 750))
 189         self.SetTopWindow(frame)
 190         frame.Show(True)
 191 
 192         return True
 193 
 194 #---------------------------------------------------------------------------
 195 
 196 def main():
 197     app = MyApp(False)
 198     app.MainLoop()
 199 
 200 #---------------------------------------------------------------------------
 201 
 202 if __name__ == "__main__" :
 203     main()


Sample two

img_sample_two.png

   1 # sample_two.py
   2 
   3 import wx
   4 
   5 # class MyPanel
   6 # class MyFrame
   7 # class MyApp
   8 
   9 #---------------------------------------------------------------------------
  10 
  11 class MyPanel(wx.Panel):
  12     def __init__(self, *args, **kwargs):
  13         wx.Panel.__init__(self, *args, **kwargs)
  14 
  15         self.Bind(wx.EVT_PAINT, self.OnPaint)
  16 
  17     #-----------------------------------------------------------------------
  18 
  19     def OnPaint(self, event):
  20         """
  21         ...
  22         """
  23 
  24         pdc = wx.PaintDC(self)
  25         gc = wx.GCDC(pdc)
  26         gc.Clear()
  27 
  28         #------------
  29         # Bitmap.
  30         #------------
  31 
  32         x = 100
  33         y = 30
  34 
  35         # bmp, pt, useMask=False
  36         # or
  37         # bitmap, x, y, useMask=False
  38         gc.DrawBitmap(wx.Bitmap("python.png"), x, y, True)
  39         gc.DrawText("Bitmap", int(x+150), int(y+20))
  40 
  41         #------------
  42         # Icon.
  43         #------------
  44 
  45         x = 100
  46         y = 130
  47 
  48         # icon, pt
  49         # or
  50         # icon, x, y
  51         gc.DrawIcon(wx.Icon("icon_wxWidgets.ico"), x, y)
  52         gc.DrawText("Icon", int(x+75), int(y+20))
  53 
  54         #------------
  55         # Arc.
  56         #------------
  57 
  58         gc.SetPen(wx.Pen("black", 2))
  59         gc.SetBrush(wx.Brush((204, 85, 248, 128)))
  60 
  61         x1 = 100
  62         y1 = 260
  63         x2 = 340
  64         y2 = 335
  65         x = 160
  66         y = 220
  67 
  68         # ptStart, ptEnd, centre
  69         # or
  70         # xStart, yStart, xEnd, yEnd, xc, yc
  71         gc.DrawArc(x1, y1, x2, y2, x, y)
  72         gc.DrawText("Arc", int(x+80), int(y+30))
  73 
  74         #------------
  75         # Polygon.
  76         #------------
  77 
  78         gc.SetPen(wx.Pen("blue", 2))
  79         gc.SetBrush(wx.Brush("#cacaca"))
  80 
  81         points = [(80, 140),
  82                   (130, 170),
  83                   (130, 140),
  84                   (170, 110)
  85                   ]
  86         x = 20
  87         y = 220
  88 
  89         # points, xoffset=0, yoffset=0, fill_style=ODDEVEN_RULE
  90         gc.DrawPolygon(points, x, y)
  91         gc.DrawText("Polygon", int(x+150), int(y+140))
  92 
  93         #------------
  94         # Spline.
  95         #------------
  96 
  97         gc.SetPen(wx.Pen("red", 2))
  98         gc.SetBrush(wx.Brush("pink"))
  99 
 100         points = [(100, 435),
 101                   (140, 435),
 102                   (145, 495),
 103                   (185, 495)
 104                   ]
 105 
 106         # x1, y1, x2, y2, x3, y3
 107         # or
 108         # points
 109         gc.DrawSpline(points)
 110         gc.DrawText("Spline", int(x+180), int(y+250))
 111 
 112         #------------
 113         # Point.
 114         #------------
 115 
 116         gc.SetPen(wx.Pen("purple", 80))
 117 
 118         x = 100
 119         y = 555
 120 
 121         # pt
 122         # or
 123         # x, y
 124         gc.DrawPoint (x, y)
 125         gc.DrawText("Point", int(x+20), int(y-10))
 126 
 127         #------------
 128         # Text.
 129         #------------
 130 
 131         x = 150
 132         y = 620
 133 
 134         gc.DrawText("Text", int(x+100), int(y))
 135 
 136         gc.SetTextForeground("red")
 137         font = wx.Font(36, wx.ROMAN, wx.ITALIC, wx.NORMAL)
 138         gc.SetFont(font)
 139 
 140         # text, pt
 141         # or
 142         # text, x, y
 143         gc.DrawText("Hello !", x-50, y-20)
 144 
 145 
 146 #---------------------------------------------------------------------------
 147 
 148 class MyFrame(wx.Frame):
 149     def __init__(self, *args, **kwargs):
 150         wx.Frame.__init__(self, *args, **kwargs)
 151 
 152         #------------
 153 
 154         frameicon = wx.Icon("icon_wxWidgets.ico")
 155         self.SetIcon(frameicon)
 156 
 157         #------------
 158 
 159         self.Panel = MyPanel(self)
 160 
 161 #---------------------------------------------------------------------------
 162 
 163 
 164 class MyApp(wx.App):
 165     """
 166     ...
 167     """
 168     def OnInit(self):
 169 
 170         #------------
 171 
 172         frame = MyFrame(None, title="Sample_two", size=(380, 750))
 173         self.SetTopWindow(frame)
 174         frame.Show(True)
 175 
 176         return True
 177 
 178 #---------------------------------------------------------------------------
 179 
 180 def main():
 181     app = MyApp(False)
 182     app.MainLoop()
 183 
 184 #---------------------------------------------------------------------------
 185 
 186 if __name__ == "__main__" :
 187     main()


Sample three

img_sample_three.png

   1 # sample_three.py
   2 
   3 import wx
   4 
   5 # class MyPanel
   6 # class MyFrame
   7 # class MyApp
   8 
   9 #---------------------------------------------------------------------------
  10 
  11 class MyPanel(wx.Panel):
  12     def __init__(self, *args, **kwargs):
  13         wx.Panel.__init__(self, *args, **kwargs)
  14 
  15         self.Bind(wx.EVT_PAINT, self.OnPaint)
  16 
  17     #-----------------------------------------------------------------------
  18 
  19     def OnPaint(self, event):
  20         """
  21         ...
  22         """
  23 
  24         pdc = wx.PaintDC(self)
  25         gc = wx.GCDC(pdc)
  26         gc.Clear()
  27 
  28         #------------
  29         # Elliptic arc.
  30         #------------
  31 
  32         pen = wx.Pen("black", 2, wx.SOLID)
  33         pen.SetCap(wx.CAP_BUTT)
  34         gc.SetPen(pen)
  35         gc.SetBrush(wx.GREEN_BRUSH)
  36 
  37         x = 100
  38         y = 30
  39         w = 50
  40         h = 50
  41         r = 270
  42 
  43         # pt, sz, sa, ea
  44         # or
  45         # x, y , width, height, start, end
  46         gc.DrawEllipticArc(x, y, w, h, 0, r)
  47         gc.DrawText("Elliptic arc", int(x+w+10), int(y+h/2))
  48 
  49         #------------
  50         # Lines.
  51         #------------
  52 
  53         gc.SetPen(wx.Pen("purple", 4))
  54 
  55         points = [(20, 160),
  56                   (100, 160),
  57                   (20, 110),
  58                   (100, 110)
  59                   ]
  60         x = 90
  61         y = 20
  62 
  63         # points, xoffset=0, yoffset=0
  64         gc.DrawLines(points, x, y)
  65         gc.DrawText("Lines", int(x+120), int(y+125))
  66 
  67         #------------
  68         # Gradient fill linear.
  69         #------------
  70 
  71         x = 100
  72         y = 240
  73         w = 100
  74         h = 100
  75 
  76         gc.GradientFillLinear((x, y, w, h),
  77                               "#ff6b1a",
  78                               "#000000",
  79                               wx.NORTH)
  80         # rect, initialColour, destColour, nDirection=RIGHT)
  81         gc.DrawText("Gradient fill linear", int(x+115), int(y+40))
  82 
  83         #------------
  84         # Gradient fill concentric.
  85         #------------
  86 
  87         x = 100
  88         y = 380
  89         w = 100
  90         h = 100
  91 
  92 
  93         # Note : currently this function is very slow,
  94         # don’t use it for real-time drawing.
  95 
  96         # rect, initialColour, destColour
  97         # or
  98         # rect, initialColour, destColour
  99         gc.GradientFillConcentric((x, y, w, h),
 100                                   "#61c3ff",
 101                                   "#000000",
 102                                   (50, 50))
 103         # rect, initialColour, destColour, circleCenter)
 104         gc.DrawText("Gradient fill concentric", int(x+115), int(y+40))
 105 
 106 #---------------------------------------------------------------------------
 107 
 108 class MyFrame(wx.Frame):
 109     def __init__(self, *args, **kwargs):
 110         wx.Frame.__init__(self, *args, **kwargs)
 111 
 112         #------------
 113 
 114         frameicon = wx.Icon("icon_wxWidgets.ico")
 115         self.SetIcon(frameicon)
 116 
 117         #------------
 118 
 119         self.Panel = MyPanel(self)
 120 
 121 #---------------------------------------------------------------------------
 122 
 123 
 124 class MyApp(wx.App):
 125     """
 126     ...
 127     """
 128     def OnInit(self):
 129 
 130         #------------
 131 
 132         frame = MyFrame(None, title="Sample_three", size=(380, 580))
 133         self.SetTopWindow(frame)
 134         frame.Show(True)
 135 
 136         return True
 137 
 138 #---------------------------------------------------------------------------
 139 
 140 def main():
 141     app = MyApp(False)
 142     app.MainLoop()
 143 
 144 #---------------------------------------------------------------------------
 145 
 146 if __name__ == "__main__" :
 147     main()


Sample four

img_sample_four.png

   1 # sample_four.py
   2 
   3 import wx
   4 
   5 # class MyPanel
   6 # class MyFrame
   7 # class MyApp
   8 
   9 #---------------------------------------------------------------------------
  10 
  11 class MyPanel(wx.Panel):
  12     def __init__(self, *args, **kw):
  13         wx.Panel.__init__(self, *args, **kw)
  14 
  15         self.Bind(wx.EVT_PAINT, self.OnPaint)
  16 
  17     #-----------------------------------------------------------------------
  18 
  19     def OnPaint(self, evt):
  20         """
  21         ...
  22         """
  23 
  24         gc = wx.GraphicsContext.Create(wx.PaintDC(self))
  25 
  26         pen = wx.Pen("navy", 2)
  27         gc.SetPen(pen)
  28         brush = wx.Brush((255,32,32,128))
  29         gc.SetBrush(brush)
  30         gc.PushState()
  31 
  32         path = gc.CreatePath()
  33         path.MoveToPoint(50, 50)
  34         path.AddLineToPoint(25,25)
  35         path.AddLineToPoint(50,25)
  36         path.AddLineToPoint(50,50)
  37         path.CloseSubpath()
  38 
  39         gc.DrawPath(path)
  40 
  41         gc.Scale(2,2)
  42         gc.Translate(10,5)
  43         gc.DrawPath(path)
  44 
  45         gc.Translate(50,0)
  46         gc.FillPath(path)
  47         gc.Translate(0,5)
  48         gc.StrokePath(path)
  49         gc.Translate(0,5)
  50 
  51         brush = wx.Brush((32,32,255,128))
  52         gc.SetBrush(brush)
  53 
  54         gc.FillPath(path)
  55         gc.Translate(50,0)
  56         gc.DrawPath(path)
  57 
  58         gc.PopState()
  59 
  60         points = [ (5.2, 5.9),
  61                    (50, 50),
  62                    (35, 50),
  63                    (25,40),
  64                    wx.Point2D(20.5,50.9),
  65                    wx.Point2D(5,25),
  66                    (5,6)
  67                    ]
  68 
  69         gc.Translate(40, 150)   #
  70         gc.DrawLines(points)
  71         gc.Translate(75, 0)
  72         gc.StrokeLines(points)
  73 
  74         begin = [ (0,0),
  75                   (0,10),
  76                   (0,20),
  77                   (0,30),
  78                   (0,40),
  79                   (0,50),
  80                   ]
  81 
  82         end   = [ (50,0),
  83                   (50,10),
  84                   (50,20),
  85                   (50,30),
  86                   (50,40),
  87                   (50,50),
  88                   ]
  89 
  90         # In a floating point coordinate system the center of the
  91         # pixel is actually at x+0.5, y+0.5, so with anti-aliasing
  92         # turned on we'll get a crisper line by positioning our line
  93         # segments at the 0.5 offset.  For this test we'll just let
  94         # the GC do the translation for us.
  95         gc.Translate(0.5, 0.5)
  96 
  97         pen = wx.Pen("purple", 1)
  98         gc.SetPen(pen)
  99 
 100         gc.Translate(75, 0)
 101         gc.StrokeLineSegments(begin, end)
 102 
 103         gc.Translate(75, 0)
 104         gc.Scale(2,2)
 105         gc.StrokeLineSegments(begin, end)
 106         gc.DrawLines(points)
 107 
 108         del path
 109 
 110 #---------------------------------------------------------------------------
 111 
 112 class MyFrame(wx.Frame):
 113     def __init__(self, *args, **kwargs):
 114         wx.Frame.__init__(self, *args, **kwargs)
 115 
 116         #------------
 117 
 118         frameicon = wx.Icon("icon_wxWidgets.ico")
 119         self.SetIcon(frameicon)
 120 
 121         #------------
 122 
 123         self.Panel = MyPanel(self)
 124 
 125 #---------------------------------------------------------------------------
 126 
 127 
 128 class MyApp(wx.App):
 129     """
 130     ...
 131     """
 132     def OnInit(self):
 133 
 134         #------------
 135 
 136         frame = MyFrame(None, title="Sample_four", size=(420, 320))
 137         self.SetTopWindow(frame)
 138         frame.Show(True)
 139 
 140         return True
 141 
 142 #---------------------------------------------------------------------------
 143 
 144 def main():
 145     app = MyApp(False)
 146     app.MainLoop()
 147 
 148 #---------------------------------------------------------------------------
 149 
 150 if __name__ == "__main__" :
 151     main()


Sample five

img_sample_five.png

   1 # sample_five.py
   2 
   3 """
   4 
   5 ZetCode wxPython tutorial.
   6 
   7 This program performs set operations on regions.
   8 
   9 Author      : Jan Bodnar
  10 Website     : zetcode.com
  11 link        : http://www.zetcode.com/wxpython/gdi/
  12 Last edited : May 2018
  13 
  14 --------
  15 
  16 Region operations :
  17 
  18 Regions can be combined to create more complex shapes.
  19 We can use four set operations : union, intersect, substract, xor.
  20 
  21 The following example shows all four operations in action.
  22 
  23 --------
  24 
  25 In the example, we present six region set operations.
  26 
  27 region1 = wx.Region(100, 20, 50, 50)
  28 region2 = wx.Region(110, 40, 50, 50)
  29 region1.Intersect(region2)
  30 
  31 """
  32 
  33 import wx
  34 
  35 # class MyFrame
  36 # class MyApp
  37 
  38 #---------------------------------------------------------------------------
  39 
  40 class MyFrame(wx.Frame):
  41     def __init__(self, *args, **kw):
  42         super(MyFrame, self).__init__(*args, **kw)
  43 
  44         #------------
  45 
  46         self.SetIcon(wx.Icon('icon_wxWidgets.ico'))
  47         self.SetSize((300, 250))
  48         self.SetMinSize((300, 250))
  49         self.SetBackgroundColour("yellow")
  50 
  51         #------------
  52 
  53         # Simplified init method.
  54         self.InitUI()
  55 
  56     #-----------------------------------------------------------------------
  57 
  58     def InitUI(self):
  59         """
  60         ...
  61         """
  62 
  63         self.Bind(wx.EVT_PAINT, self.OnPaint)
  64 
  65         self.SetTitle("Sample five (regions)")
  66         self.Centre()
  67 
  68 
  69     def OnPaint(self, event):
  70         """
  71         ...
  72         """
  73 
  74         dc = wx.PaintDC(self)
  75         dc.SetPen(wx.Pen('#000000'))
  76 
  77         dc.DrawRectangle(20, 20, 50, 50)
  78         dc.DrawRectangle(30, 40, 50, 50)
  79 
  80         dc.SetBrush(wx.Brush('#ffffff'))
  81         dc.DrawRectangle(100, 20, 50, 50)
  82         dc.DrawRectangle(110, 40, 50, 50)
  83 
  84         region1 = wx.Region(100, 20, 50, 50)
  85         region2 = wx.Region(110, 40, 50, 50)
  86         region1.Intersect(region2)
  87 
  88         rect = region1.GetBox()
  89         dc.SetDeviceClippingRegion(region1)
  90         dc.SetBrush(wx.Brush('#ff0000'))
  91         dc.DrawRectangle(rect)
  92         dc.DestroyClippingRegion()
  93 
  94         dc.SetBrush(wx.Brush('#ffffff'))
  95         dc.DrawRectangle(180, 20, 50, 50)
  96         dc.DrawRectangle(190, 40, 50, 50)
  97 
  98         region1 = wx.Region(180, 20, 50, 50)
  99         region2 = wx.Region(190, 40, 50, 50)
 100         region1.Union(region2)
 101         dc.SetDeviceClippingRegion(region1)
 102 
 103         rect = region1.GetBox()
 104         dc.SetBrush(wx.Brush('#fa8e00'))
 105         dc.DrawRectangle(rect)
 106         dc.DestroyClippingRegion()
 107 
 108         dc.SetBrush(wx.Brush('#ffffff'))
 109         dc.DrawRectangle(20, 120, 50, 50)
 110         dc.DrawRectangle(30, 140, 50, 50)
 111         region1 = wx.Region(20, 120, 50, 50)
 112         region2 = wx.Region(30, 140, 50, 50)
 113         region1.Xor(region2)
 114 
 115         rect = region1.GetBox()
 116         dc.SetDeviceClippingRegion(region1)
 117         dc.SetBrush(wx.Brush('#619e1b'))
 118         dc.DrawRectangle(rect)
 119         dc.DestroyClippingRegion()
 120 
 121         dc.SetBrush(wx.Brush('#ffffff'))
 122         dc.DrawRectangle(100, 120, 50, 50)
 123         dc.DrawRectangle(110, 140, 50, 50)
 124         region1 = wx.Region(100, 120, 50, 50)
 125         region2 = wx.Region(110, 140, 50, 50)
 126         region1.Subtract(region2)
 127 
 128         rect = region1.GetBox()
 129         dc.SetDeviceClippingRegion(region1)
 130         dc.SetBrush(wx.Brush('#715b33'))
 131         dc.DrawRectangle(rect)
 132         dc.DestroyClippingRegion()
 133 
 134         dc.SetBrush(wx.Brush('#ffffff'))
 135         dc.DrawRectangle(180, 120, 50, 50)
 136         dc.DrawRectangle(190, 140, 50, 50)
 137         region1 = wx.Region(180, 120, 50, 50)
 138         region2 = wx.Region(190, 140, 50, 50)
 139         region2.Subtract(region1)
 140 
 141         rect = region2.GetBox()
 142         dc.SetDeviceClippingRegion(region2)
 143         dc.SetBrush(wx.Brush('#0d0060'))
 144         dc.DrawRectangle(rect)
 145         dc.DestroyClippingRegion()
 146 
 147 #---------------------------------------------------------------------------
 148 
 149 class MyApp(wx.App):
 150     def OnInit(self):
 151 
 152         #------------
 153 
 154         frame = MyFrame(None)
 155         self.SetTopWindow(frame)
 156         frame.Show(True)
 157 
 158         return True
 159 
 160 #---------------------------------------------------------------------------
 161 
 162 def main():
 163     app = MyApp(False)
 164     app.MainLoop()
 165 
 166 #---------------------------------------------------------------------------
 167 
 168 if __name__ == "__main__" :
 169     main()


Download source

source.zip


Additional Information

Link :

http://zetcode.com/wxpython/gdi/

https://wiki.wxpython.org/Draw%20a%20rounded%20rectangle%20%28Phoenix%29

https://wiki.wxpython.org/Draw%20an%20elliptic%20arc%20%28Phoenix%29

- - - - -

https://wiki.wxpython.org/TitleIndex

https://docs.wxpython.org/


Thanks to

Cody Precord (sample_four.py coding), Jan Bodnar (sample_five.py coding), Chris Barker and the wxPython community...


About this page

Date(d/m/y) Person (bot) Comments :

11/01/20 - Ecco (Created page for wxPython Phoenix).


Comments

- blah, blah, blah...

Basic drawing (Phoenix) (last edited 2020-03-21 15:12:07 by Ecco)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.