Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to create a console in GUI app using pyqt?
Forum Update on Monday, May 27th 2025

How to create a console in GUI app using pyqt?

Scheduled Pinned Locked Moved Unsolved Qt for Python
9 Posts 3 Posters 12.6k 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
    Moeka_Chan
    wrote on last edited by
    #1

    Does anyone have an idea?
    I used QTextEdit and QLineEdit to create a console.
    I used eval to run custom command.
    Is it the correct method to do it?

    jsulmJ 1 Reply Last reply
    0
    • M Moeka_Chan

      Does anyone have an idea?
      I used QTextEdit and QLineEdit to create a console.
      I used eval to run custom command.
      Is it the correct method to do it?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Moeka_Chan said in How to create a console in GUI app using pyqt?:

      Is it the correct method to do it?

      Depends on what you mean with "console". Do you want to embed the console of your system (which OS is it?) into your app?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Moeka_Chan said in How to create a console in GUI app using pyqt?:

        Is it the correct method to do it?

        Depends on what you mean with "console". Do you want to embed the console of your system (which OS is it?) into your app?

        M Offline
        M Offline
        Moeka_Chan
        wrote on last edited by
        #3

        @jsulm My OS is windows 10. I want to embed python console. Also, the console can run my custom command. I don't find any tutorials related it from Google... It should be like console in Blender.

        jsulmJ 1 Reply Last reply
        0
        • M Moeka_Chan

          @jsulm My OS is windows 10. I want to embed python console. Also, the console can run my custom command. I don't find any tutorials related it from Google... It should be like console in Blender.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Moeka_Chan Did you already check this: https://docs.python.org/2/extending/embedding.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • M Offline
            M Offline
            Moeka_Chan
            wrote on last edited by
            #5

            @Denni-0 I want to interact with the terminal window. I am a Blender user. I can create a customized class or function to run in Blender. I think I need to create a widget for a console to be added in my App. There is no console widget, but PyqtGraph has consolewidget. I also checked console application, script window, command window, console interface, dev console. Because they are shown in App GUI, I don't know what correct word to search...

            One more question, some games have their own console. For example, players can change a mouse cursor size or select game server in Dota 2 console. I am not sure whether I can create some variables, like a = 2, in Dota 2 console. (I didn't test it before). Do you have any ideas on how to create this console?

            1 Reply Last reply
            0
            • jsulmJ jsulm

              @Moeka_Chan Did you already check this: https://docs.python.org/2/extending/embedding.html

              M Offline
              M Offline
              Moeka_Chan
              wrote on last edited by
              #6

              @jsulm No. I will check it later.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Moeka_Chan
                wrote on last edited by Moeka_Chan
                #7

                @Denni-0
                0_1563514628781_QQ图片20190719013657.png
                0_1563514548949_QQ图片20190719013514.png
                I want to create my own program that has a console. It is like Command Window in Matlab or Console in Blender, which is shown in the red rectangle in the images above.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Moeka_Chan
                  wrote on last edited by
                  #8

                  @Denni-0 Most of the software I used has a scripting section. For example, Motionbuilder, Maya, Blender, Unity, Matlab... Users can write their scripts to run there. Currently, I am not going to add this feature in my program. Usually, the scripting section includes TextEdit for scripting and a console to run some internal functions or execute the scripts. I am going to create a console in my program, but I have no blueprint on it. I found a tutorial showing how to create a dev console on a webpage, and it used TextEdit and LineEdit to achieve it. However, the console in the tutorial only works for customized command. It can't run any Python, Java method.....

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Moeka_Chan
                    wrote on last edited by
                    #9

                    @Denni-0 wrap it and then call a python or command line execute function to run it
                    Does it use methods like eval, subprocess?

                    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