Deprecation Warnings on Floats

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 = aDC

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

Gordon Williams wrote:

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 = aDC

def 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):

Don't derive from a DC, wrap one that is passed in to the constructor. See my message to Jean-Michel for more details.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!