Embedding a Terminal into a QT Python Linux App
-
Hi,
I've wanting to create a QT Python app for linux that has an embedded terminal window, that I can pass commands to with button clicks. KParts for Python looks to be depreciated from what I can see which is what I was hoping to use, as my DE is KDE Plasma.
I have built an app that runs console commands and passes the output to a text window, but an embedded terminal would be more preferable. I seem to be struggling to find a solution to this, has anyone else been able to embed a terminal window like Konsole into their QT Python app?
-
Hi,
if you just want to send some commands, have a look at this topic
To print the response in your terminal, you could use
readAllStandardOutput()
fromQProcess
, as also mentioned in the linked topic above.And just for the design, you could build something similar to the Qt Terminal Example. It uses serial port communication, but it shouldn't matter since the design should also work for any other terminal.
-
@MeditatingHamster
To have a full terminal, and conveniently from Python, did you see @SGaist 's suggestion in How To Embed Terminal on interface in PyQt5? That is only a year old so hopefully still "current".There are other suggestions in https://stackoverflow.com/questions/52269950/how-to-embed-terminal-inside-pyqt5-application-without-qprocess or https://www.pythonguis.com/faq/pyqt5-embed-external-program-into-qwidget/, and still more from Googling
qt embed terminal
. -
Hi,
I made "qtpyTerminal" exactly for this purpose. Check it out:
https://github.com/mguijarr/qtpyTerminal
It is based on Pyte for vt100 escape codes interpretation. It relies on QPlainTextEdit,
and provides an interactive widget to execute any shell command.