Robin wrote:
Perhaps better would be to create a decorator class that is constructed
with a DC of whatever type, and wraps the methods you need and simply
forwards the rest to the real DC.
class FloatDCWrapper:
def __init__(self, aDC):
self.theDC = aDCdef DrawLine(self, x1, y1, x2, y2):
self.theDC.DrawLine(int(round(x1)), int(round(y1)),
int(round(x2)), int(round(y2)))
You lost me a bit here.
By adding the class below, I am able to plot OK, but printing is still a
problem. Ideally, I think I want to modify wxDC, but I cant see of a way to
do this.
# Hack to allow plotting real numbers
class _wxBufferedDC(wx.wxBufferedDC):
_DrawLine= wx.wxBufferedDC.DrawLine
_DrawText= wx.wxBufferedDC.DrawText
_DrawRotatedText= wx.wxBufferedDC.DrawRotatedText
_SetClippingRegion= wx.wxBufferedDC.SetClippingRegion
def __init__(self,*_args,**_kwargs):
wx.wxBufferedDC.__init__(self,*_args,**_kwargs)
def DrawLine(self, x1,y1,x2,y2):
self._DrawLine(int(x1),int(y1),int(x2),int(y2))
def DrawText(self, txt, x, y):
self._DrawText(txt, int(x), int(y))
def DrawRotatedText(self, txt, x, y, angle):
self._DrawRotatedText(txt, int(x), int(y), angle)
def SetClippingRegion(self, x, y, width, height):
self._SetClippingRegion(int(x), int(y), int(width), int(height))