[wxpython-dev] richtextstyles wrapping
Petr Šimon
sim at klubko.net
Mon Mar 24 16:52:56 PDT 2008
Robin Dunn wrote:
> Petr Šimon wrote:
>> Hello,
>> I am very much interested in wrapping the richtextstyles and related
>> stuff. I don't have much experience with swig, though. My initial
>> attempt was only partially succesful. I am getting "No constructor
>> defined" error.
>>
>> My .i file looks like this:
>> //-----------------
>> %{
>> #include <wx/richtext/richtextstyles.h>
>> %}
>> //---------------------------------------------------------------------------
>>
>> %newgroup
>> class wxRichTextStyleDefinition: public wxObject
>> {
>> public:
>> wxRichTextStyleDefinition(const wxRichTextStyleDefinition& def);
>> /// Default constructor
>> wxRichTextStyleDefinition(const wxString& name = wxPyEmptyString);
>> virtual ~wxRichTextStyleDefinition();
>>
>> /// Initialises members
>> void Init();
>>
>> /// Copies from def
>> void Copy(const wxRichTextStyleDefinition& def);
>>
>> /// Equality test
>> bool Eq(const wxRichTextStyleDefinition& def) const;
>> etc...
>>
>> My questions:
>>
>> 1. What am I doing wrong?
>
> Not sure. You do have constructors defined there...
>
>> 2. Is there a reason that the styles were not wrapped yet? Is it
>> supposed to be tricky or something?
>
> No, I just ran out of time and haven't gotten back to it yet.
>
>
I was trying to find the aswer and here
http://wiki.fifengine.de/index.php?title=Swig, they mention this:
Pitfalls
* You get *"No constructor defined"* even though you are sure that
there is constructor in interface file
o Does some of the base classes contain abstract methods that
are not defined in subclass that you try to instantiate?
+ In case all abstract methods /are/ defined in you
subclass, you can force swig to ignore abstractness by
using *%feature("notabstract") YOURCLASS;*
o Have you defined your methods correctly to be public
(remember that in case there is no "public:" stated, methods
are private)
I can't make much out of it. Some classes work just fine, but there are
69 cases of def __init__(self): raise AttributeError, "No constructor
defined" in wxPython. Mostly it seems harmless since those seem to be
ABCs and subclass overrides the constructor (also meaning that python
can't subclass those base classes, which is probably OK).
I still don't understand why RichTextStyleDefinition doesn't work, but
I'll leave it and wrap the rest, since RichTextCharacterStyleDefinition
and ...Paragraph... seem to work just fine.
Petr
More information about the wxpython-dev
mailing list