Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Embedding a Terminal into a QT Python Linux App

Embedding a Terminal into a QT Python Linux App

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MeditatingHamster
    wrote on 2 May 2023, 12:29 last edited by
    #1

    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?

    P J 2 Replies Last reply 2 May 2023, 12:40
    0
    • M MeditatingHamster
      2 May 2023, 12:29

      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?

      P Offline
      P Offline
      Pl45m4
      wrote on 2 May 2023, 12:40 last edited by Pl45m4 5 Feb 2023, 12:41
      #2

      @MeditatingHamster

      Hi,

      if you just want to send some commands, have a look at this topic

      • https://forum.qt.io/topic/113592/run-command-line-from-qt-app-in-linux

      To print the response in your terminal, you could use
      readAllStandardOutput() from QProcess, 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.

      • https://doc.qt.io/qt-6.2/qtserialport-terminal-example.html

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • M MeditatingHamster
        2 May 2023, 12:29

        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?

        J Offline
        J Offline
        JonB
        wrote on 2 May 2023, 13:03 last edited by
        #3

        @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.

        M 1 Reply Last reply 2 May 2023, 18:56
        4
        • J JonB
          2 May 2023, 13:03

          @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.

          M Offline
          M Offline
          MeditatingHamster
          wrote on 2 May 2023, 18:56 last edited by
          #4

          @JonB Thanks, it looks like QTermWidget was the way to go for me. After installing qtermwidget-git from the AUR I was able to import via "from QTermWidget import QTermWidget".

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mguijarr
            wrote on 16 Sept 2024, 09:08 last edited by
            #5

            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.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved