예제 #1
0
QString PyQcsObject::getCsStringChannel(QString channel, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);

	if (e != NULL) {
		CSOUND *cs = e->getCsound();

		if (cs != NULL) {
#ifdef CSOUND6
			int maxlen = csoundGetChannelDatasize(cs, channel.toLocal8Bit());
#else
			int maxlen = csoundGetStrVarMaxLen(cs);
#endif
			char *value = new char[maxlen];
			if ( !( csoundGetChannelPtr(cs,(MYFLT **) &value,channel.toLocal8Bit(),
										CSOUND_STRING_CHANNEL | CSOUND_OUTPUT_CHANNEL))) {
				return QString(value);
			}
		}
	}
	QString message="Could not read from channel "+channel;
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
	return QString();//m_qcs->getCsChannel(channel, index);

}
예제 #2
0
파일: main.cpp 프로젝트: abletterer/CGoGN-1
int main( int argc, char **argv )
{
  QApplication qapp(argc, argv);

  PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
  PythonQt_QtAll::init();

  PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();

  bool showConsole = false;
  QStringList files;
  for (int i = 1; i < argc; i++) {
    QString arg = argv[i];
    QString argLower = arg.toLower();
    if (argLower == "-console" || argLower == "-c") {
      showConsole = true;
    } else {
      QString file = arg;
      QFileInfo info(file);
      if (info.exists()) {
        files << info.absoluteFilePath();
        // add the file's absolute path for local importing
        PythonQt::self()->addSysPath(info.absolutePath());
      } else {
        QMessageBox::warning(NULL, "PyLauncher", QString("File does not exist: %1").arg(file));
      }
    }
  }
  PythonQtScriptingConsole console(NULL, mainContext);

  Q_FOREACH(QString file, files) {
    mainContext.evalFile(file);
  }
예제 #3
0
void PythonQtTestSlotCalling::initTestCase()
{
  _helper = new PythonQtTestSlotCallingHelper(this);
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();
  main.evalScript("import PythonQt");
  PythonQt::self()->addObject(main, "obj", _helper);
}
예제 #4
0
//----------------------------------------------------------------------------
void DolfinGui::updateGeometry(Geometry *geometry)
{
    // Use python script to obtain values in QLineEdit boxes
    PythonQt::init();
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("infoBox", geometry->getInfoBox());
    double *points = new double[geometry->getPointCount()];
    double *radius = new double[geometry->getRadiusCount()];

    std::cout << "Points: " << std::endl;
    for (int i=0; i < geometry->getPointCount(); ++i){
        points[i] = mainModule.evalScript(QString("eval(infoBox.pointEdit%1.text)").arg(i),
                Py_eval_input).toDouble();
        std::cout << i << ": " << points[i] << std::endl;
    }

    if (geometry->getRadiusCount() > 0){
        for (int i=0; i < geometry->getRadiusCount(); ++i){
            radius[i] = mainModule.evalScript(QString("eval(infoBox.radiusEdit%1.text)").arg(i),
                                              Py_eval_input).toDouble();
        }
    }

    geometry->setPoints(points);
    geometry->setRadius(radius);
    geometry->setGeometryPointer(generateGeometry(geometry));

    std::cout << "Point count: " << geometry->getPointCount() << std::endl;
    plotGeometry();
}
예제 #5
0
void PyQcsObject::setCsChannel(QString channel, double value, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *p;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
#ifndef CSOUND6
        if (cs != NULL && !(csoundGetChannelPtr(cs, &p, channel.toLocal8Bit(), CSOUND_CONTROL_CHANNEL | CSOUND_INPUT_CHANNEL))) {
            *p = (MYFLT) value;
            return;
        }
#else
        if (cs) {
            controlChannelHints_t hints;  // this does not work with csound5
			int ret = csoundGetControlChannelHints(cs, channel.toLocal8Bit(), &hints);
			if (ret == 0) {
				csoundSetControlChannel(cs, channel.toLocal8Bit(), (MYFLT) value);
				return;
			}
		}
#endif
    }

	QString message="Channel '" + channel + "' does not exist or is not exposed with chn_k.";
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
}
예제 #6
0
bool WebDavInventoryDataModel::FetchWebdavUrlWithIdentity()
{
    pythonQtMainModule_.evalScript("import connection\n");
    PythonQtObjectPtr httpclient = pythonQtMainModule_.evalScript("connection.HTTPClient()\n", Py_eval_input);

    // Some url verification, remove http:// and everything after the port
    int index = hostUrl_.indexOf("http://");
    if (index != -1)
        hostUrl_ = hostUrl_.midRef(index+7).toString();
    index = hostUrl_.indexOf("/");
    if (index != -1)
        hostUrl_ = hostUrl_.midRef(0, index).toString();

    // Set up HTTP connection to Taiga WorldServer
    httpclient.call("setupConnection", QVariantList() << hostUrl_ << "openid" << identityUrl_);
    // Get needed webdav access urls from Taiga WorldServer
    QStringList resultList = httpclient.call("requestIdentityAndWebDavURL").toStringList();
    // Store results
    if (resultList.count() < 1)
        return false;

    webdavIdentityUrl_ = resultList.value(0);
    webdavUrl_ = resultList.value(1);

    return true;
}
예제 #7
0
void PyQcsObject::setDocument(int index)
{
	QString name = m_qcs->setDocument(index);
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	QString path = name.left(name.lastIndexOf("/"));
	mainContext.call("os.chdir", QVariantList() << path );
	mainContext.evalScript("print 'cd \"" + path + "\"'");
}
예제 #8
0
void PythonQtTestApi::testDynamicProperties()
{
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();

  // this fails and should fail, but how could that be tested?
  // main.evalScript("obj.testProp = 1");
  
  // create a new dynamic property
  main.evalScript("obj.setProperty('testProp','testValue')");

  // read the property
  QVERIFY(QString("testValue") == main.getVariable("obj.testProp").toString());
  // modify and read again
  main.evalScript("obj.testProp = 12");
  QVERIFY(12 == main.getVariable("obj.testProp").toInt());

  // check if dynamic property is in dict
  QVERIFY(12 == main.evalScript("obj.__dict__['testProp']", Py_eval_input).toInt());

  // check if dynamic property is in introspection
  QStringList l = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything);
  QVERIFY(l.contains("testProp"));
  
  // check with None, previous value expected
  main.evalScript("obj.testProp = None");
  QVERIFY(12 == main.getVariable("obj.testProp").toInt());

  // remove the dynamic property
  main.evalScript("obj.setProperty('testProp', None)");

  // check if dynamic property is really gone
  QStringList l2 = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), "obj", PythonQt::Anything);
  QVERIFY(!l2.contains("testProp"));
  
}
예제 #9
0
void PythonQtTestApi::testProperties()
{
  PythonQtObjectPtr main = PythonQt::self()->getMainModule();
  // check for name alias (for backward comp to Qt3)
  main.evalScript("obj.name = 'hello'");
  QVERIFY(QString("hello") == main.getVariable("obj.name").toString());

  main.evalScript("obj.objectName = 'hello2'");
  QVERIFY(QString("hello2") == main.getVariable("obj.objectName").toString());

}
예제 #10
0
int PyQcsObject::loadDocument(QString name, bool runNow)
{
	QDir d(name);
	d.makeAbsolute();
	qDebug() << d.absolutePath();
	if (!QFile::exists(d.absolutePath())) {
		PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
		mainContext.evalScript("print 'File not found.'");
		return -1;
	} else {
		return m_qcs->loadFile(d.absolutePath(), runNow);
	}
}
예제 #11
0
QList< Calamares::job_ptr >
PythonQtViewStep::jobs() const
{
    QList< Calamares::job_ptr > jobs;

    PythonQtObjectPtr jobsCallable = PythonQt::self()->lookupCallable( m_obj, "jobs" );
    if ( jobsCallable.isNull() )
        return jobs;

    PythonQtObjectPtr response = PythonQt::self()->callAndReturnPyObject( jobsCallable );
    if ( response.isNull() )
        return jobs;

    PythonQtObjectPtr listPopCallable = PythonQt::self()->lookupCallable( response, "pop" );
    if ( listPopCallable.isNull() )
        return jobs;

    forever
    {
        PythonQtObjectPtr aJob = PythonQt::self()->callAndReturnPyObject( listPopCallable, { 0 } );
        if ( aJob.isNull() )
            break;

        jobs.append( Calamares::job_ptr( new PythonQtJob( m_cxt, aJob ) ) );
    }

    return jobs;
}
예제 #12
0
QVariant PyQcsObject::getWidgetProperty(QString widgetid, QString property, int index)
{
	QStringList properties = listWidgetProperties(widgetid,index);
	if ( properties.contains(property) ) {
		return m_qcs->getWidgetProperty(widgetid, property, index);

	} else {

		QString message="Widget "+widgetid+" does not have property "+property+" available properties are: "+properties.join(", ")+".";
		PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
		mainContext.evalScript("print \'"+message+"\'");
	}
	return (int) -1;
}
예제 #13
0
void PyQcsObject::setCsChannel(QString channel, QString stringValue, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *p;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
		if (cs != NULL && !(csoundGetChannelPtr(cs, &p, channel.toLocal8Bit().constData(), CSOUND_STRING_CHANNEL | CSOUND_INPUT_CHANNEL))) {
			// FIXME not thread safe and not checking string bounds.
			strcpy((char*) p,stringValue.toLocal8Bit().constData() );
			return;
		}
	}
	QString message="Could not set string into channel "+ channel;
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
}
예제 #14
0
QVariant
lookupAndCall( PyObject* object,
               const QStringList& candidateNames,
               const QVariantList& args,
               const QVariantMap& kwargs )
{
    Q_ASSERT( object );
    Q_ASSERT( !candidateNames.isEmpty() );

    for ( const QString& name : candidateNames )
    {
        PythonQtObjectPtr callable = PythonQt::self()->lookupCallable( object, name );
        if ( callable )
            return callable.call( args, kwargs );
    }

    // If we haven't found a callable with the given names, we force an error:
    return PythonQt::self()->call( object, candidateNames.first(), args, kwargs );
}
예제 #15
0
int main( int argc, char **argv )
{
  QApplication qapp(argc, argv);

  PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
  PythonQt_QtAll::init();

  PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();
  PythonQtScriptingConsole console(NULL, mainContext);

  // add a QObject to the namespace of the main python context
  PyExampleObject example;
  mainContext.addObject("example", &example);

  mainContext.evalFile(":example.py");

  console.show();
  return qapp.exec();
}
예제 #16
0
double PyQcsObject::getCsChannel(QString channel, int index)
{
	CsoundEngine *e = m_qcs->getEngine(index);
	MYFLT *value =  new MYFLT;
	//*value = 0;
	if (e != NULL) {
		CSOUND *cs = e->getCsound();
		if (cs != NULL ) {
			if ( !( csoundGetChannelPtr(cs,&value,channel.toLocal8Bit(),
										CSOUND_CONTROL_CHANNEL | CSOUND_OUTPUT_CHANNEL)))
				return (double) *value;
		}
	}

	QString message="Could not read from channel "+channel;
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
	mainContext.evalScript("print \'"+message+"\'");
	return 0;//m_qcs->getCsChannel(channel, index);
}
예제 #17
0
파일: main.cpp 프로젝트: abletterer/CGoGN-1
int main(int argc, char* argv[])
{
	QApplication app(argc, argv);

	QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png"));
	splash->show();
	splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter);

	// init PythonQt and Python itself
	PythonQt::init();

	QStringList classNames;
	classNames.append("View");
	classNames.append("Camera");
	classNames.append("Plugin");
	classNames.append("MapHandlerGen");
	PythonQt::self()->registerQObjectClassNames(classNames);

	// get a smart pointer to the __main__ module of the Python interpreter
	PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule();

	PythonQtScriptingConsole* pythonConsole = new PythonQtScriptingConsole(NULL, pythonContext);

	CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, *pythonConsole);

	schnapps.show();

	pythonContext.addObject("schnapps", &schnapps);

	if(argc > 1)
	{
		QString filename(argv[1]);
		QFileInfo fi(filename);
		if (fi.exists())
			//pythonContext.evalFile(fi.filePath());
			schnapps.loadPythonScriptFromFile(fi.filePath());
	}

	splash->finish(&schnapps);
	delete splash;

	return app.exec();;
}
예제 #18
0
void milxQtPythonConsole::executeCode(const QString& code)
{
    // put visible cursor to the end of the line
    QTextCursor cursor = QTextEdit::textCursor();
    cursor.movePosition(QTextCursor::End);
    setTextCursor(cursor);

    //~ int cursorPosition = this->textCursor().position();

    // evaluate the code
    _stdOut = "";
    _stdErr = "";
    PythonQtObjectPtr p;
    PyObject* dict = NULL;
    if (PyModule_Check(_context))
    {
        dict = PyModule_GetDict(_context);
    }
    else if (PyDict_Check(_context))
    {
        dict = _context;
    }
    if (dict)
    {
        p.setNewRef(PyRun_String(code.toLatin1().data(), Py_single_input, dict, dict));
    }

    if (!p)
    {
        PythonQt::self()->handleError();
    }

    flushStdOut();

    //~ bool messageInserted = (this->textCursor().position() != cursorPosition);

    //~ // If a message was inserted, then put another empty line before the command prompt
    //~ // to improve readability.
    //~ if (messageInserted) {
    //~ append(QString());
    //~ }
}
예제 #19
0
//-----------------------------------------------------------------------------
QVariant ctkAbstractPythonManager::executeString(const QString& code,
                                                 ctkAbstractPythonManager::ExecuteStringMode mode)
{
  int start = -1;
  switch(mode)
    {
    case ctkAbstractPythonManager::FileInput: start = Py_file_input; break;
    case ctkAbstractPythonManager::SingleInput: start = Py_single_input; break;
    case ctkAbstractPythonManager::EvalInput:
    default: start = Py_eval_input; break;
    }

  QVariant ret;
  PythonQtObjectPtr main = ctkAbstractPythonManager::mainContext();
  if (main)
    {
    ret = main.evalScript(code, start);
    }
  return ret;
}
예제 #20
0
int PyQcsObject::newDocument(QString name)
{
	PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();

	if (name.isEmpty()) {
		mainContext.evalScript("print 'Please specify a filename'");
		return -1;
	}
	QDir d(name);
	qDebug() << d;
	if (QFile::exists(d.absolutePath())) {
		mainContext.evalScript("print 'File already exists. Use loadDocument()'");
		return -1;
	}
	m_qcs->newFile();
	if (!m_qcs->saveFile(d.absolutePath())) {
		mainContext.evalScript("print 'Error saving file.'");
	}
	return m_qcs->getDocument(name);
}
예제 #21
0
//----------------------------------------------------------------------------
void DolfinGui::updateSphere(SphereGeometry *sphere){

    std::cout << "In method updateSphere(): \n";
    std::cout << "-------- HELLO!!! --------" << std::endl;

    // Use python script to obtain values for corner points
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("sphereInfoBox", sphere->getInfoBox());
    for (int i=0; i<sphere->getPointCount(); ++i)
        sphere->getPoints()[i] = mainModule.evalScript(QString("eval(sphereInfoBox.sphereEdit%1.text)").arg(i),
                                            Py_eval_input).toDouble();

    // Use python script to obtain values for radius
    for (int i=0; i<sphere->getRadiusCount(); ++i)
        sphere->getRadius()[i] = mainModule.evalScript(QString("eval(sphereInfoBox.radiusEdit%1.text)").arg(i),
                                            Py_eval_input).toDouble();

    plotSphere(sphere);
    sphereSelected = false;
}
예제 #22
0
파일: main.cpp 프로젝트: Alzathar/PythonQt
int main( int argc, char **argv )
{
  QApplication qapp(argc, argv);

  PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);

  PythonQtObjectPtr  mainContext = PythonQt::self()->getMainModule();
  PythonQtScriptingConsole console(NULL, mainContext);

  // register the type with QMetaType
  qRegisterMetaType<CustomObject>("CustomObject");
  // add a wrapper object for the new variant type
  PythonQt::self()->registerCPPClass("CustomObject","","example", PythonQtCreateObject<CustomObjectWrapper>);

  mainContext.evalFile(":example.py");

  console.appendCommandPrompt();
  console.show();

  return qapp.exec();
}
예제 #23
0
    void PythonScriptModule::Uninitialize()
    {
        // Clear script created input contexts.
        createdInputs_.clear();

        PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
        if (!mainModule.isNull())
        {
            mainModule.removeVariable("_pythonscriptmodule");
            mainModule.removeVariable("_tundra");
        }

        // This will remove all the signal handlers in PythonQt.
        // This function is only available in the modified PythonQt realXtend Tundra made.
        // Otherwise our app will crash when deleting the framework APIs as there are connected signals still to python slots.
        LogInfo("PythonScriptModule: Disconnecting all PythonQt connected signals");
        PythonQt::priv()->disconnectAllSignalReceivers();
        PythonQt::priv()->deleteAllSignalReceivers();

        // Note that we do not call Py_Finalize() before or after PythonQt::cleanup()
        // as this will crash either way after doing the above. Let python release its memory when the dll is unloaded.
        LogInfo("PythonScriptModule: Running PythonQt cleanup");
        PythonQt::cleanup();
    }
예제 #24
0
//----------------------------------------------------------------------------
void DolfinGui::updateCone(ConeGeometry *cone){

    std::cout << "In method updateCone(): \n";
    std::cout << "-------- HELLO!!! --------" << std::endl;

    for (int i=0; i<6; ++i)
        std::cout << cone->getPoints()[i] << " " << std::endl;

    // Use python script to obtain values for corner points
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("coneInfoBox", cone->getInfoBox());
    for (int i=0; i<cone->getPointCount(); ++i)
        cone->getPoints()[i] = mainModule.evalScript(QString("eval(coneInfoBox.coneEdit%1.text)").arg(i),
                                            Py_eval_input).toDouble();

    // Use python script to obtain values for radius
    for (int i=0; i<cone->getRadiusCount(); ++i)
        cone->getRadius()[i] = mainModule.evalScript(QString("eval(coneInfoBox.radiusEdit%1.text)").arg(i),
                                            Py_eval_input).toDouble();

    plotCone(cone);
    std::cout << "Ferdig" << std::endl;
    //coneSelected = false;
}
예제 #25
0
//----------------------------------------------------------------------------
void DolfinGui::updateCube(CubeGeometry *cube)
{
    // Set up arrays to hold information about corner points
    //GeometryInfo *cubeInfo = new GeometryInfo(6);
    //double dataList[cube->getPointCount()];
    //cube->setPoints(dataList);

    updateRequested = true;
    std::cout << "In method updateCube(): \n";
    std::cout << "-------- HELLO!!! --------" << std::endl;
    //for (int i=0; i<6; ++i)
    //    std::cout << cube->getPoints()[i] << " " << std::endl;

    // Use python script to obtain new values for corner points
    PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
    mainModule.addObject("cubeInfoBox", cube->getInfoBox());
    for (int i=0; i<cube->getPointCount(); ++i){
        cube->getPoints()[i] = mainModule.evalScript(QString("eval(cubeInfoBox.cubeEdit%1.text)").arg(i),
                                            Py_eval_input).toDouble();

    }
    plotCube(cube);
    cubeSelected = false;
}
예제 #26
0
bool CPythonNode::data(QString gate_name, const CConstDataPointer &data)
{
    Q_UNUSED(gate_name);

    if(data->getType() == "table") {
        // Get the table data structured received.
        QSharedPointer<const CTableData> p_table = data.staticCast<const CTableData>();
        // Create a table data structure to forward.
        QSharedPointer<CTableData> result_table = QSharedPointer<CTableData>(
                    static_cast<CTableData *>(createData("table")));

        QString script_name = getConfig().getParameter("input_script")->value.toString();
        // Start a new python context independant of any other.
        PythonQtObjectPtr module = PythonQt::self()->createUniqueModule();
        // Evaluate the user-supplied python script.
        module.evalFile(script_name);
        // Call the 'main' function of the user script with the received table
        // ... and a table that will contatin the results as arguments.
        QVariant result = module.call("main",
            QVariantList() << QVariant::fromValue(p_table.data())
                           << QVariant::fromValue(result_table.data()));
        if(result.toBool()) {
            commit("out", result_table);
        }

        return true;
    }
    else if(data->getType() == "tcpstreams") {
        // The TCP Streams data structure.
        QSharedPointer<const CTcpStreamsData> p_flows = data.staticCast<const CTcpStreamsData>();
        // Create a table data structure to forward.
        QSharedPointer<CTableData> result_table = QSharedPointer<CTableData>(
                    static_cast<CTableData *>(createData("table")));

        QString script_name = getConfig().getParameter("input_script")->value.toString();
        // Start a new python context independant of any other.
        PythonQtObjectPtr module = PythonQt::self()->createUniqueModule();
        // Evaluate the user-supplied python script.
        module.evalFile(script_name);
        // Call the 'main' function of the user script with the received table
        // ... and a table that will contatin the results as arguments.
        QVariant result = module.call("main",
            QVariantList() << QVariant::fromValue(p_flows.data())
                           << QVariant::fromValue(result_table.data()));

        // If the python script returned true, commit the results' table.
        if(result.toBool()) {
            commit("out", result_table);
        }

        return true;
    }

    return false;
}
예제 #27
0
    void PythonScriptModule::PostInitialize()
    {
        // An error has occurred on startup.
        if (!pythonQtStarted_)
            return;

        // Get python main module.
        PythonQtObjectPtr mainModule = PythonQt::self()->getMainModule();
        if (mainModule.isNull())
        {
            LogError("PythonScriptModule::StartPythonQt(): Failed to get main module from PythonQt after init!");
            return;
        }

        // Add PythonScriptModule as '_pythonscriptmodule' 
        // and Framework as '_tundra' to python.
        mainModule.addObject("_pythonscriptmodule", this);
        mainModule.addObject("_tundra", GetFramework());

        QDir pythonPlugins(Application::InstallationDirectory() + "pyplugins");
        QDir pythonLibrary(pythonPlugins.absoluteFilePath("python/"));

        // Add Tundra python plugins source location.
        AddSystemPath(pythonPlugins.absolutePath());
        AddSystemPath(pythonPlugins.absoluteFilePath("lib"));

        // Add Python Library DLL and on windows pass whole python as a archive file.
        /// \todo Is the 'DLLs' really needed also outside windows?
        AddSystemPath(pythonLibrary.absoluteFilePath("DLLs"));
#ifdef _WIN32            
        AddSystemPath(pythonLibrary.absoluteFilePath("Python26.zip"));
#endif

        // Connect to SceneAPI
        QObject::connect(GetFramework()->Scene(), SIGNAL(SceneAdded(const QString&)), this, SLOT(OnSceneAdded(const QString&)));

        // Console commands to ConsoleAPI
        GetFramework()->Console()->RegisterCommand("PyExec", "Execute given code in the embedded Python interpreter. Usage: PyExec(mycodestring)", 
                                                   this, SLOT(ConsoleRunString(const QStringList&)));
        GetFramework()->Console()->RegisterCommand("PyLoad", "Execute a python file. Usage: PyLoad(mypymodule)", 
                                                   this, SLOT(ConsoleRunFile(const QStringList&)));
        GetFramework()->Console()->RegisterCommand("PyRestart", "Restarts the Tundra Python ModuleManager", 
                                                   this, SLOT(ConsoleRestartPython(const QStringList&)));
        GetFramework()->Console()->RegisterCommand("PyConsole", "Creates a new Python console window.", 
                                                   this, SLOT(ShowConsole()));

        // Done in PostInitialize() so all modules/APIs are loaded and initialized.
        //StartPythonModuleManager();
        
        // --p --python --pythonapitests are special command line options that on purpose not put
        // to the Framework program options parsing. So lets do a special parse here for there hidden variables.
        /// \todo See if we should return --p --python as official cmd line options back to Framework. Probably best to have modules give own params somehow, 
        /// we should not mess python specific things to core SDK params in Framework.cpp :I
        namespace po = boost::program_options;

        po::variables_map commandLineVariables;
        po::options_description commandLineDescriptions;

        commandLineDescriptions.add_options()
            ("p", po::value<std::string>(), "Run a python script on startup")
            ("python", po::value<std::string>(), "Run a python script on startup")
            ("pythonapitests", "Run a python api test script on startup");

        try
        {
            /// \note QApplication::argc() and QApplication::argv() are deprecated.
            po::store(po::command_line_parser(QApplication::argc(), QApplication::argv()).options(commandLineDescriptions).allow_unregistered().run(), commandLineVariables);
        }
        catch(std::exception &e)
        {
            LogWarning(Name() + ": " + + e.what());
        }
        po::notify(commandLineVariables);

        if (commandLineVariables.count("python"))
            RunScript(commandLineVariables["python"].as<std::string>().c_str());
        if (commandLineVariables.count("p"))
            RunScript(commandLineVariables["p"].as<std::string>().c_str());

        LoadStartupScripts();
    }