SVGFileDC pen and brush support

ABC <[email protected]> Sat, 16 Mar 2019 14:35:54 -0700 (PDT)
Newsgroups gmane.comp.python.wxpython.devel
Message-ID <[email protected]>
When drawing to SVGFileDC, I see 2 errors regarding pen and brush styles:
1.
DrawLine() produces an error, when pen styles are either wx.DOT, 
wx.DOT_DASH or wx.SHORT_DASH, but wx.SOLID works fine.
Here's the error:
wx._core.wxAssertionError: C++ assertion "false" failed at 
..\..\src\common\dcsvg.cpp(84) in `anonymous-namespace'::wxPenString(): 
wxSVGFileDC::Requested Pen Style not available

2.
DrawRectangle() produces an error, when brush styles are either 
wx.CROSSDIAG_HATCH, wx.BDIAGONAL_HATCH or wx.FDIAGONAL_HATCH, but wx.SOLID 
works fine.
Here's the error:
wx._core.wxAssertionError: C++ assertion "false" failed at 
..\..\src\common\dcsvg.cpp(104) in `anonymous-namespace'::wxBrushString(): 
wxSVGFileDC::Requested Brush Style not available

Enclosed a script demonstrating these issues.

-- 
You received this message because you are subscribed to the Google Groups "wxPython-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
svg_pen_brush.py (text/x-python, 2 KB)
import wx

class DrawPanel(wx.Frame):
    def __init__(self, height_, width_):
        wx.Frame.__init__(self, None, title="Draw on Panel")
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.height = height_
        self.width  = width_
        
    def draw(self, dc_):
        # lines
        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
        dc_.DrawLine(0,   0, self.width-1,   0)

        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT))
        dc_.DrawLine(0,  50, self.width-1,  50)

        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.DOT_DASH))
        dc_.DrawLine(0, 100, self.width-1, 100)

        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.SHORT_DASH))
        dc_.DrawLine(0, 150, self.width-1, 150)

        # rectangles
        #dc_.SetPen(wx.TRANSPARENT_PEN)

        dc_.SetPen(wx.Pen(wx.BLACK, 1, wx.SOLID))
        dc_.SetBrush(wx.Brush(wx.BLUE, wx.SOLID))
        dc_.DrawRectangle(50,   0, 50, 50)   # x, y, width, height

        dc_.SetPen(wx.Pen(wx.RED, 1, wx.SOLID))
        dc_.SetBrush(wx.Brush(wx.RED, wx.CROSSDIAG_HATCH))
        dc_.DrawRectangle(50,  50, 50, 50)   # x, y, width, height

        dc_.SetPen(wx.Pen(wx.YELLOW, 1, wx.SOLID))
        dc_.SetBrush(wx.Brush(wx.YELLOW, wx.BDIAGONAL_HATCH))
        dc_.DrawRectangle(50, 100, 50, 50)   # x, y, width, height

        dc_.SetPen(wx.Pen(wx.GREEN, 1, wx.SOLID))
        dc_.SetBrush(wx.Brush(wx.GREEN, wx.FDIAGONAL_HATCH))
        dc_.DrawRectangle(50, 150, 50, 50)   # x, y, width, height
    # end draw
    
    def OnPaint(self, event=None):
        dc = wx.PaintDC(self)
        dc.Clear()
        self.draw(dc)

        svgfile = wx.SVGFileDC('svg_pen_brush.svg', width = self.width, height = self.height)
        self.draw(svgfile)
        svgfile.Destroy()   # to close the output file
    # end OnPaint

# main
app   = wx.App(False)
frame_h = 200
frame_w = 200
frame = DrawPanel(frame_h, frame_w)
frame.SetClientSize((frame.width, frame.height))   # sets the size of the INSIDE of a window
frame.Show()
app.MainLoop()