0

In python I have a QtextBrowser which is fed the output of an external command. this works great Within the output is a progress update:

loadingfile
processing file
progress 5%
progress 10%
progress 25%
....
closing file
processing completed

I want to query this QTextBrowser for the 'progress X%' lines, and feed that value into an updating progress bar.

How do I read in the latest progress %? I thought I would do it by reading in the last line everytime the browser was updated, but I cant find any way to do that. I assume i have to convert the text to a Qstringlist: textBrowser.toPlainText() and then process that?

tashuhka
  • 5,028
  • 4
  • 45
  • 64
sjm1983
  • 1
  • 1

1 Answers1

0

whilst I am sure this isnt the most efficient way of going about it - I have a working solution:

doc = self.textBrowser.toPlainText()
    txt= str(doc).split('\n')

    match = 'progress '
    for prog in txt:
            if match in text:
                    prog = prog.strip('progress ')
                    prog = prog.translate(None, '%')
                    prog = int(prog)
                    self.progressBar.setValue(prog)
sjm1983
  • 1
  • 1