简体   繁体   中英

Python Programs Console inside pyqt GUI

Alright so im wanting to create a pyqt gui that has little consoles inside the program that things can be printed to. let me explain further more. so if you would run a program without any gui interface like this

import os
name = raw_input("What is your name? ")
print "Hello " + str(name) = "How are you?"
os.system('pause')

everything would run inside of the cmd. i am wanting to make a pyqt gui that is basicly the cmd but i would like to add other buttons around the embedded console if someone could teach me how to make this that would be amazing. thank you so much in advance!

You're thinking too much into this.

You want to:

  1. Show the form
  2. Make the text section read-only
  3. Run your piece of code which generates your display text
  4. Make the text section read-write
  5. Add the display text to the text section
  6. Make the text section read-only again

Use a QTextEdit to hold your text.

The command to make the QTextEdit read-only is:

QTextEdit.setReadOnly (self, bool ro)

So in practice this would be:

my_text_edit.setReadOnly(True)

and to change back to read-write:

my_text_edit.setReadOnly(False)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM