Some tweaks for PenInfo and GraphicsPenInfo wrappers

This commit is contained in:
Robin Dunn
2019-07-31 16:35:08 -07:00
parent 9e78437974
commit 0ddc262ee5
3 changed files with 20 additions and 7 deletions

View File

@@ -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)