0

I have a working progressbar in the terminal that I wrote from a tutorial. Now I am wondering if it is possible to get this into the GUI qttextbrowser as ouput?. Does somebody has any idea? thanks for your help!

Hier die progressbar:

class ProgressBar(object):

def __init__(self, message, width=20, progressSymbol=u'▣ ', emptySymbol=u'□ '):
    self.width = width

    if self.width < 0:
        self.width =0

    self.message = message 
    self.progressSymbol = progressSymbol
    self.emptySymbol = emptySymbol

def update(self, progress):
    totalBlocks = self.width
    filledBlocks =int(round(progress / (100 / float(totalBlocks)) ))
    emptyBlocks = totalBlocks - filledBlocks

    progressBar = self.progressSymbol *filledBlocks + \
        self.emptySymbol * emptyBlocks

    if not self.message:
        self.message =u''

    self.progressMessage = u'\r{0} {1}   {2}%'.format(self.message, progressBar,progress)

    sys.stdout.write(self.progressMessage)
    sys.stdout.flush()

def calculateAndUpdate(self,done,total):
    progress = int(round((done / float(total)) * 100))
    self.update(progress)

also the copy function:

p = ProgressBar('copy ...')
def copyFile_progress(src, dest):
numFiles = countFiles(src)

if numFiles > 0:
    makedirs(dest)

    numCopied = 0

    for path, dirs, filenames in os.walk(src):
        for directory in dirs:
            destDir = path.replace(src,dest)
            makedirs(os.path.join(destDir, directory))

        for sFile in filenames:
            srcFile = os.path.join(path, sFile)
            destFile = os.path.join(path.replace(src,dest), sFile)
            shutil.copy(srcFile, destFile)
            numCopied += 1
            p.calculateAndUpdate(numCopied,numFiles)
            
        print
nicBit
  • 63
  • 1
  • 2
  • 8
  • Does it really have to be **inside** the text-browser? Why can't you use a [QProgressBar](https://doc.qt.io/qt-5/qprogressbar.html)? – ekhumoro Feb 22 '21 at 13:47
  • i want to have it like an terminal output ... so i can see whats happend – nicBit Feb 23 '21 at 06:40

0 Answers0