1

I need some help or/and suggestions here, I'm making a Python program with GUI using pyQT, but I need to output realtime subprocess command into a textbrowser, so that way the user could see if there's any error and the message error, alternative make a progress bar and interrumpt the program saying to the user there was an error and maybe save a log, or any other idea that could work, I already found something like this in internet:

process = Popen([command],stdout=PIPE)
                while True:
                    line = process.stdout.readline()
                    if not line:
                        break
                    QtWidgets.QApplication.processEvents()
                    self.textBrowser.append(str(line.strip()))

And that kinda works but, it won't print the output in realtime, just when finish the command, and also it freezes the GUI while working.

A part from that problem I have, there's something else, the command I'm trying to run will ask to the user to press Enter when there's a error for continue, so, assuming all that, isn't there any way to embedd a terminal on the python program or open a new terminal and launch the command there? This way the user will see the output in realtime and possible errors and press Enter if there's any error for continue.

This is for Linux

So any ideas? I would appreciate any idea/sugestion/help, thanks!

Klairm
  • 31
  • 4

1 Answers1

0

Consider putting this long process in a thread, Qthread for instance

How to make QtGui window process events whenever it is brought forward on the screen?

https://doc.qt.io/archives/qq/qq27-responsive-guis.html

Naib
  • 999
  • 7
  • 20