-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (39 loc) · 1.73 KB
/
Copy pathmain.cpp
File metadata and controls
47 lines (39 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <QApplication>
#include "pyrun.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
/** PART I *********************************************************/
PyRun *pyRun = new PyRun();
/** Test for running from string */
qDebug("\nRun from string...");
char* string = "from time import time, ctime\n"
"print('Today is', ctime(time()))\n";
pyRun->runString(string);
/** Test for running from python file, for '__main__' */
qDebug("\nRun from file...");
//Abosulte path is needed
QString fName = "/home/yzy/Desktop/qtTest/QtPythonEmbedding/runtest.py";
pyRun->runFile(fName);
/** Test for running from python file, and run certain function
* This implementation is similar with that calling pyRun->runModuleFunction(),
* the difference is that in this implementation, the whole python script
* firstly executes.
*/
qDebug("\nRun certain function from python file...");
pyRun->runFileFunction(fName, "test");
/** Test for importing module, for certain function
* NOTE: path of imported module should set in inner function, which should
* be improved further.
*/
qDebug("\nRun certain function through module importing...");
pyRun->runModuleFunction("runtest", "main");
/** End of PART I *********************************************************/
/** PART III *********************************************************/
/** Test for embedded interpreter */
// PyRun *pyRunMain = new PyRun(argc, argv);
// //If calling following function, it fails...
// //pyRun->runEmbInterpreter(argc, argv);
/** End of PART III *******************************************************/
return a.exec();
}