MCPcopy Create free account
hub / github.com/commontk/CTK / push

Method push

Libs/Scripting/Python/Widgets/ctkPythonConsole.cpp:573–607  ·  view source on GitHub ↗

----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

571
572//----------------------------------------------------------------------------
573bool ctkPythonConsolePrivate::push(const QString& code)
574{
575 Q_ASSERT(this->PythonManager);
576
577 bool ret_value = false;
578
579 QString buffer = code;
580 // The embedded python interpreter cannot handle DOS line-endings, see
581 // http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=1167922
582 buffer.remove('\r');
583 PyErr_Clear(); // make sure we are not in an error state before we execute the command
584 PyObject *res = PyObject_CallMethod(this->InteractiveConsole,
585 const_cast<char*>("push"),
586 const_cast<char*>("z"),
587#if PY_MAJOR_VERSION >= 3
588 buffer.toUtf8().data());
589#else
590 buffer.toLatin1().data());
591#endif
592 if (res)
593 {
594 int status = 0;
595 if (PyArg_Parse(res, "i", &status))
596 {
597 ret_value = (status > 0);
598 }
599 Py_DECREF(res);
600 }
601 else
602 {
603 // error occurred
604 PyErr_Clear();
605 }
606 return ret_value;
607}
608
609//----------------------------------------------------------------------------
610void ctkPythonConsolePrivate::printWelcomeMessage()

Callers 6

resizePopupMethod · 0.80
readNextMethod · 0.80
topologicalSortMethod · 0.80
executeCommandMethod · 0.80

Calls 2

removeMethod · 0.45
dataMethod · 0.45

Tested by 2