diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2018-12-14 17:20:25 +0100 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2018-12-14 17:20:25 +0100 |
commit | e0b4a2eeab91696e54d9ff3acc319d99ab9b96f9 (patch) | |
tree | 79b6bc1d50c75b6b7bb78b5d842d9c75178c4a09 /gui/pyconsole.cc | |
parent | 19cffde375fe63e36bfd880727bdc0a04a2ccf32 (diff) | |
download | nextpnr-e0b4a2eeab91696e54d9ff3acc319d99ab9b96f9.tar.gz nextpnr-e0b4a2eeab91696e54d9ff3acc319d99ab9b96f9.tar.bz2 nextpnr-e0b4a2eeab91696e54d9ff3acc319d99ab9b96f9.zip |
Add GUI for executing python file
Diffstat (limited to 'gui/pyconsole.cc')
-rw-r--r-- | gui/pyconsole.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gui/pyconsole.cc b/gui/pyconsole.cc index 0ee393ce..d015aea2 100644 --- a/gui/pyconsole.cc +++ b/gui/pyconsole.cc @@ -76,4 +76,21 @@ void PythonConsole::moveCursorToEnd() setTextCursor(cursor); } +void PythonConsole::execute_python(std::string filename) +{ + int errorCode = 0; + std::string res; + res = pyinterpreter_execute_file(filename.c_str(), &errorCode); + if (res.size()) { + if (errorCode) { + setTextColor(ERROR_COLOR); + } else { + setTextColor(OUTPUT_COLOR); + } + append(res.c_str()); + setTextColor(NORMAL_COLOR); + moveCursorToEnd(); + } +} + NEXTPNR_NAMESPACE_END |