richtextstyles wrapping

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?
2. Is there a reason that the styles were not wrapped yet? Is it supposed to be tricky or something?

Thaks for help
Petr

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.

···

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

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 Home · fifengine/fifengine Wiki · GitHub, 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

Petr Šimon wrote:

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...

I still don't understand why RichTextStyleDefinition doesn't work, but

You don't show the full class above, do you have the "= 0" at the end of the declaration for the Clone method? If so then SWIG is going to recognize it as a pure virtual method and will not let you create instances of it. (Since I had my own style of dealing with ABCs before SWIG was smart enough to deal with them itself, I always leave out the "= 0"'s and just comment out the constructor declaration myself. It accomplishes the same thing.

···

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