4

アプリケーションのステータス バーにプログレス バーを追加したいと考えています。この投稿を見つけましたが、使用が機能してinsertWidget()いないようです。

4

1 に答える 1

11

insertWidget()メソッドを使用する代わりに、代わりに使用しますaddPermanentWidget()

次に例を示します。

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()

これにより、次のようなものが生成されます。

プログレスバー

于 2013-07-29T19:08:16.260 に答える