[PyQt] sip cmodule.cpp
Bart
uzi18 at o2.pl
Mon Apr 9 13:16:32 BST 2007
> On Saturday 07 April 2007 11:49 pm, Bart wrote:
>
>> I have some questions:
>> 1. Why sip don't generate also name_of_module_cmodule.h ?
>>
>
> Because there is no need for it.
>
>
>> 2. Why in name_of_module_cmodule.cpp there is no deinit_module() function?
>> I'm asking because after Py_Finalize() and PyInitialize();init_module();
>> have application crash.
>>
>
> The module initialisation function is only meant to be called by the
> interpreter.
>
> Phil
>
>
But ... for statically-linked module I must call init_module_function()
directly after Py_Initialize();
http://docs.python.org/ext/methodTable.html
Maybe I done something wrong and that's why have got problem.
It is possible to deinit this sip generated module?
Thanks a lot for Your help.
Just for clear :
[uzi at uzi python_scripting]$ cat kadu.sip
%Module kadu
%Import qt/qtmod.sip
%Include about.sip
[uzi at uzi python_scripting]$ cat about.sip
class About : QHBox
{
%TypeHeaderCode
#include "kadu-headers/about.h"
%End
public:
About(QWidget *parent /TransferThis/, const char
*name=NULL);
~About();
};
[uzi at uzi python_scripting]$ cat kadu-headers/about.h
#ifndef ABOUT_H
#define ABOUT_H
#include <qstring.h>
#include <qhbox.h>
#include <qwidget.h>
class LayoutHelper;
class QResizeEvent;
class About : public QHBox {
Q_OBJECT
public:
About(QWidget *parent=NULL, const char *name=NULL);
~About();
private:
QString loadFile(const QString &name);
void keyPressEvent(QKeyEvent *);
LayoutHelper *layoutHelper;
protected:
virtual void resizeEvent(QResizeEvent *);
};
#endif
In plugin module
on load :
Python::Python()
{
Py_Initialize();
initkadu();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n"
"from qt import *\n"
"print '1'\n"
"import kadu\n"
"print '2'\n"
"kadu.About()\n"
"print '3'\n"
"dir([])\n"
"print '4'\n");
}
on unload :
Python::~Python()
{
Py_Finalize();
}
More information about the PyQt
mailing list