[wxPython] Re: wxPython-users digest, Vol 1 #340 - 14 msgs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[wxPython] Re: wxPython-users digest, Vol 1 #340 - 14 msgs

Toby Perkins
> From: Niki Spahiev <[hidden email]>
> Toby Perkins <[hidden email]> wrote:
> > ...
> > How about a cross-parser-documenter script (in Python, natch)?  A littl
> Such beast exist and is called SWIG. IMHO it will be hard to make minimal

Thanks to Niki.  (...and apologies to all the other folks on the list
while us newbies fumble around trying to help each other.)

Dear fellow newbies:

SWIG seems to work well as the tool I had in mind.  I downloaded SWIG
(www.swig.org), maked it, and installed it, following the clear
instructions, and read a few pages of  how-to.  Then I picked (with no
rhyme/reason) some C++ functions out of the wxWindows/wxPython
documentation.  Happened to be BitMap.  I copied a handful of C++
functions, eliminating overloaded functions (function names appearing
more than once, with different stuff inside their parentheses), two
extremely nasty C++ keywords ("static" and "virtual") and the C++
destructor function (which has a tilde), all of which made SWIG choke.
Then I mechanically put an "extern" at the front of every function
declaration and a semicolon at the end.  I didn't have to generate any
Python constructors, because the doc already shows them.  Here is my
final SWIG ".i" file:

%module BitMap
%{
/* Nothing needed here*/
%}

extern void AddHandler(wxBitmapHandler* handler);
extern void CleanUpHandlers();
extern bool Create(int width, int height, int depth = -1);
extern wxBitmapHandler* FindHandler(const wxString& name);
extern int GetDepth() const;
extern wxList& GetHandlers();
extern int GetHeight() const;
extern wxPalette* GetPalette() const;
extern wxMask* GetMask() const;
extern int GetWidth() const;
extern wxBitmap GetSubBitmap(const wxRect&rect) const;
extern void InitStandardHandlers();
extern void InsertHandler(wxBitmapHandler* handler);
extern bool LoadFile(const wxString& name, long type);

All nasty stuff you can't read, right?  I saved this file as
"BitMap.i".  Then I typed "swig -python -c++ BitMap.i" on the command
line, opened the "BitMap_wrap.doc" file that swig created, and walla.  I
don't know if the functions in the .doc file actually work in wxPython,
come to think of it, but they sure look Pythonish.  Try it out.

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: wxPython-users digest, Vol 1 #340 - 14 msgs

Nicolas Chauvat-2
> Thanks to Niki.  (...and apologies to all the other folks on the list
> while us newbies fumble around trying to help each other.)
>
> Dear fellow newbies:
>
> SWIG seems to work well as the tool I had in mind.  I downloaded SWIG
> (www.swig.org), maked it, and installed it, following the clear
> instructions, and read a few pages of  how-to.

For an introduction to swig and python, you may also have a look at the
february issue of the linux gazette (www.linuxgazette.com)

-- Nicolas

 (o-  Hi, I'm a deadly e-mail virus, please copy me into your .signature
 /\   file to help me spread. :: Bonjour, je suis un dangereux virus. SVP
Y_/_  copiez-moi dans votre fichier .signature pour m'aider à me propager.    


_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users



Reply | Threaded
Open this post in threaded view
|

Re: [wxPython] Re: wxPython-users digest, Vol 1 #340 - 14 msgs

Toby Perkins
Nicolas Chauvat wrote:
...
> february issue of the linux gazette (www.linuxgazette.com).
I found it in the january issue.  :-)

_______________________________________________
wxPython-users maillist  -  [hidden email]
http://starship.python.net/mailman/listinfo/wxpython-users