How do I call the wxImageHandler constructor from
my derived class?
The code in image.py looks like this:
class wxImageHandler(wxImageHandlerPtr):
def __init__(self,this):
self.this = this
I can't make a 'this'. The other code in there implies
that it could be a imagec.new_wxImageHandler() but that
doesn't exist.
The doc for wxImageHandler constructor also says that I
have to set some m_ variables in my derived class
constructor. It doesn't look like those variables are
wrapped, so I assume I need to call the various Set*
methods instead. Are they safe to call in my constructor?
(BTW my image handler is for the Brew Compressed Image
format which is used on most CDMA cellphones in the
US for wallpaper etc. The reading code works well and
has been shipping with BitPim for a while. There is
no writing code as the image has to be converted down
to 256 palette entries and none of the functionality
in wx makes that feasible to do. I am now doing the
"right thing" by writing an ImageHandler rather than
having special case code testing for BCI wherever I
load images. If there is any interest in this, I would
be happy to donate it to wxPython.)
call the wxImageHandler constructor from your derived class like this:
class CustomImageHandler(wxImageHandler):
def __init__(self,*arg,**kwds):
wxImageHandler.__init__(self,*arg,**kwds)
That won't work. wxImageHandler requires a 'this' parameter.
It is generated by Swig, except in this case. This is probably
because the intention was for wxImageHandler to be abstract.
Your code above makes some other code supply it, but since I
am also writing the other code, doesn't solve the problem.
I think it is just an oversight in the wrappers. I am
probably the first person to try an write an ImageHandler
in Python since some other stuff is somewhat broken if
you write one as well.
How do I call the wxImageHandler constructor from my derived class?
The wrapper for wxImageHandler has not yet been engineered to allow derived Python classes (it takes extra work for each overridable virtual method to allow it.) I'll add it to my TODO list.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!