##// END OF EJS Templates
updated changelog...
updated changelog git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@40 ea8d5007-eb21-0410-b261-ccb3ea6e24a9

File last commit:

r2:b0bd6d44c879
r5:14f0a8a666fd
Show More
CPPPyWrapperExample.cpp
34 lines | 1.3 KiB | text/x-c | CppLexer
ezust
- Added CHANGELOG...
r2 #include <PythonQt.h>
#include <QtGui>
int main (int argc, char* argv[]) {
QApplication app(argc, argv);
PythonQt::init();
PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
Q_ASSERT(!mainModule.isNull());
{
// evaluate a python file embedded in executable as resource:
mainModule.evalFile(":eyed3tagger.py");
PythonQtObjectPtr tag = mainModule.evalScript("EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
qDebug() << "test1";
{ // alternative using import and loading it as a real module from sys.path
// import sys first
mainModule.evalScript(QString("import sys\n"));
// append the current directory to the sys.path
mainModule.evalScript(QString("sys.path.append('%1')\n").arg(QDir::currentPath()));
mainModule.evalScript("import eyed3tagger\n");
PythonQtObjectPtr tag = mainModule.evalScript("eyed3tagger.EyeD3Tagger()\n", Py_eval_input);
Q_ASSERT(!tag.isNull());
tag.call("setFileName", QVariantList() << "t.mp3");
QVariant fn = tag.call("fileName", QVariantList());
Q_ASSERT(fn.toString() == QString("t.mp3"));
}
qDebug() << "finished";
return 0;
}