Hello,
I’ve been trying to draw custom gauges via wxPython using the standard graphics context, and while this is straightforward, it’s fairly tedious. I was hoping to design the gauges with an SVG editor like Inkscape, load them into a custom
wx.PyControl, and animate the moving parts to speed up the design process. From some googling, it looks like Cairo integration and librsvg is the most common solution. My control is pretty standard and renders properly with the standard graphics context
drawing. The most relevant (I think) part of the code follows:
def OnPaint(self, event):
dc = wx.BufferedPaintDC(self)
dc.SetBackground(wx.Brush(‘gray’))
dc.Clear()
self.Draw(dc)
def Draw(self, dc):
width, height = self.GetClientSize()
if not width or not height:
return
ctx = wx.lib.wxcairo.ContextFromDC(dc)
print “Context:”, ctx
ctx.paint()
When is runs, I get a small white box on a black background, and as soon as the first redraw occurs, I receive the following error over and over again rapidly:
RuntimeError: maximum recursion depth exceeded while calling a Python object
Exception RuntimeError: ‘maximum recursion depth exceeded while calling a Python object’ in ignored
Traceback (most recent call last):
File “C:_PROJECTS\advanced_gauge\gauge.py”, line 45, in OnPaint
dc = wx.BufferedPaintDC(self)
RuntimeError
Cairo seems available because the following sets hasCairo to True:
try:
import wx.lib.wxcairo
import cairo
haveCairo = True
except ImportError:
haveCairo = False
I have been following the example at
http://xy-27.pythonxy.googlecode.com/hg-history/0b7c0c0bd5a5cc63dcc505285052e210b126ab0b/src/python/wxPython/DOC/demo/Cairo.py. I am using Python 2.7 x32 on Windows 7 x64 with wx.version = 2.8.12.1.
Would appreciate any tips or suggestions on how to debug this or better approach the problem.
Thanks,
Louis