Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a ProgressBar to the StatusBar using PySide?

I'm wanting to add a progress bar into my application's status bar. I've found this post, however using insertWidget() doesn't appear to be working.

like image 789
James Mertz Avatar asked Dec 26 '22 23:12

James Mertz


1 Answers

Instead of using the insertWidget() method use instead addPermanentWidget().

Here's an example:

class SampleBar(gui.QMainWindow):
    """Main Application"""


    def __init__(self, parent = None):
        print('Starting the main Application')
        super(SampleBar, self).__init__()
        self.initUI()

    def initUI(self):
        # Pre Params:
        self.setMinimumSize(800, 600)

        # File Menus & Status Bar:
        self.statusBar().showMessage('Ready')
        self.progressBar = gui.QProgressBar()


        self.statusBar().addPermanentWidget(self.progressBar)

        # This is simply to show the bar
        self.progressBar.setGeometry(30, 40, 200, 25)
        self.progressBar.setValue(50)

def main():
    app = gui.QApplication(sys.argv)
    main = SampleBar()
    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

This should produce something like this:

Progress Bar

like image 51
James Mertz Avatar answered Dec 28 '22 12:12

James Mertz