<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 進度條 > 原文: [https://pythonbasics.org/Progressbar/](https://pythonbasics.org/Progressbar/) `QProgressBar`是顯示過程的小部件。 您可能在安裝過??程中多次看到它。 小部件顯示一個條,您可以看到完成的百分比。 您可以使用方法`setValue()`設置其值。 如果將 50 設置為 50%。 ## `QProgressBar` ### 進度條 使用下面的代碼創建進度條: ```py self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 200, 25) ``` 您可以使用以下方法設置值: ```py self.pbar.setValue(50) ``` 這就是創建進度條所需的全部。 要更新其值,您可以使用`QTimer`。 ```py from PyQt5.QtCore import QBasicTimer ``` 每秒用以下幾行調用一個方法: ```py self.timer = QTimer() self.timer.timeout.connect(self.handleTimer) self.timer.start(1000) ``` 然后更新進度條值: ```py def handleTimer(self): value = self.pbar.value() if value < 100: value = value + 1 self.pbar.setValue(value) else: self.timer.stop() ``` ![progressbar pyqt](https://img.kancloud.cn/bf/6c/bf6c87dea0b8c05acc5fa8336e1ba1a3_334x244.jpg) ### 示例 復制下面的代碼以查看進度條從 50% 到 100% 的計數。使用`handleTimer()`和`QTimer()`方法更新進度條。 ```py import sys from PyQt5.QtCore import QTimer from PyQt5.QtWidgets import QApplication, QMainWindow, QProgressBar from PyQt5.QtCore import Qt class Example(QMainWindow): def __init__(self): super().__init__() self.pbar = QProgressBar(self) self.pbar.setGeometry(30, 40, 200, 25) self.pbar.setValue(50) self.setWindowTitle("QT Progressbar Example") self.setGeometry(32,32,320,200) self.show() self.timer = QTimer() self.timer.timeout.connect(self.handleTimer) self.timer.start(1000) def handleTimer(self): value = self.pbar.value() if value < 100: value = value + 1 self.pbar.setValue(value) else: self.timer.stop() if __name__ == '__main__': app = QApplication(sys.argv) ex = Example() sys.exit(app.exec_()) ``` [下載示例](https://gum.co/pysqtsamples)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看