From 0ddc262ee58911702dc7bd1a4d3c9aba9ecd308f Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 31 Jul 2019 16:35:08 -0700 Subject: [PATCH] Some tweaks for PenInfo and GraphicsPenInfo wrappers --- etg/graphics.py | 4 ++++ etg/pen.py | 3 +++ wx/lib/graphics.py | 20 +++++++++++++------- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/etg/graphics.py b/etg/graphics.py index f7cf9949..256349f3 100644 --- a/etg/graphics.py +++ b/etg/graphics.py @@ -281,6 +281,10 @@ def run(): # GraphicsPenInfo is transitory we can't save the reference in it to the # holder, and the pen will not have been created yet... c.find('Dashes').ignore() + c.find('GetDashes').ignore() + c.find('GetDashCount').ignore() + c.find('GetDash').ignore() + #--------------------------------------------- diff --git a/etg/pen.py b/etg/pen.py index 17b1ef31..78a27df5 100644 --- a/etg/pen.py +++ b/etg/pen.py @@ -111,6 +111,9 @@ def run(): # transitory we can't save the reference in it to the holder, and the pen # will not have been created yet... c.find('Dashes').ignore() + c.find('GetDashes').ignore() + c.find('GetDashCount').ignore() + c.find('GetDash').ignore() # it is delay-initialized, see stockgdi.sip diff --git a/wx/lib/graphics.py b/wx/lib/graphics.py index a9d309bb..e5ebe560 100644 --- a/wx/lib/graphics.py +++ b/wx/lib/graphics.py @@ -197,12 +197,14 @@ class GraphicsPen(GraphicsObject): @staticmethod def CreateFromPen(pen): - """Convert a :class:`wx.Pen` to a ``GraphicsPen``""" - assert isinstance(pen, wx.Pen) - p = GraphicsPen(pen.Colour, pen.Width, pen.Style) - p._cap = pen.Cap - p._dashes = pen.Dashes - p._join = pen.Join + """Convert a :class:`wx.Pen` or :class:`wx.GraphicsPenInfo` to a ``GraphicsPen``""" + assert isinstance(pen, (wx.Pen, wx.GraphicsPenInfo)) + p = GraphicsPen(pen.GetColour(), pen.GetWidth(), pen.GetStyle()) + p._cap = pen.GetCap() + p._join = pen.GetJoin() + if isinstance(pen, wx.Pen): + # TODO: GraphicsPenInfo still needs Dashes support added. + p._dashes = pen.GetDashes() return p @@ -1330,7 +1332,7 @@ class GraphicsContext(GraphicsObject): def CreatePen(self, pen): """ - Create a new pen from a wx.Pen. + Create a new pen from a wx.Pen or a wx.GraphicsPenInfo. """ return GraphicsPen.CreateFromPen(pen) @@ -1824,6 +1826,10 @@ class GraphicsContext(GraphicsObject): self._context.paint_with_alpha(opacity) + def Flush(self): + pass + + def GetSize(self): return (self._width, self._height) Size = property(GetSize)