Skip to content
Permalink
Browse files

Some tweaks for PenInfo and GraphicsPenInfo wrappers

  • Loading branch information...
RobinD42 committed Jul 31, 2019
1 parent 01a4378 commit c4b8c35002ff6b8c2e3fff4fdd58856746d0ddfd
Showing with 20 additions and 7 deletions.
  1. +4 −0 etg/graphics.py
  2. +3 −0 etg/pen.py
  3. +13 −7 wx/lib/graphics.py
@@ -281,6 +281,10 @@ def markCreateFactories(klass):
# 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()



#---------------------------------------------
@@ -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
@@ -197,12 +197,14 @@ def __init__(self, colour=wx.BLACK, width=1, style=wx.SOLID):

@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 @@ def CreatePath(self):

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 @@ def EndLayer(self):
self._context.paint_with_alpha(opacity)


def Flush(self):
pass


def GetSize(self):
return (self._width, self._height)
Size = property(GetSize)

0 comments on commit c4b8c35

Please sign in to comment.
You can’t perform that action at this time.