久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='9Htl3'></bdo><ul id='9Htl3'></ul>
    1. <small id='9Htl3'></small><noframes id='9Htl3'>

      <i id='9Htl3'><tr id='9Htl3'><dt id='9Htl3'><q id='9Htl3'><span id='9Htl3'><b id='9Htl3'><form id='9Htl3'><ins id='9Htl3'></ins><ul id='9Htl3'></ul><sub id='9Htl3'></sub></form><legend id='9Htl3'></legend><bdo id='9Htl3'><pre id='9Htl3'><center id='9Htl3'></center></pre></bdo></b><th id='9Htl3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9Htl3'><tfoot id='9Htl3'></tfoot><dl id='9Htl3'><fieldset id='9Htl3'></fieldset></dl></div>
    2. <tfoot id='9Htl3'></tfoot>

        <legend id='9Htl3'><style id='9Htl3'><dir id='9Htl3'><q id='9Htl3'></q></dir></style></legend>

        當我將 PyQt QProgressBar 與 Selenuim 一起使用時,它不

        PyQt QProgressBar not working when I use it with Selenuim(當我將 PyQt QProgressBar 與 Selenuim 一起使用時,它不起作用)

        • <legend id='ubw6T'><style id='ubw6T'><dir id='ubw6T'><q id='ubw6T'></q></dir></style></legend>
            <bdo id='ubw6T'></bdo><ul id='ubw6T'></ul>
          • <tfoot id='ubw6T'></tfoot>

            <small id='ubw6T'></small><noframes id='ubw6T'>

          • <i id='ubw6T'><tr id='ubw6T'><dt id='ubw6T'><q id='ubw6T'><span id='ubw6T'><b id='ubw6T'><form id='ubw6T'><ins id='ubw6T'></ins><ul id='ubw6T'></ul><sub id='ubw6T'></sub></form><legend id='ubw6T'></legend><bdo id='ubw6T'><pre id='ubw6T'><center id='ubw6T'></center></pre></bdo></b><th id='ubw6T'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ubw6T'><tfoot id='ubw6T'></tfoot><dl id='ubw6T'><fieldset id='ubw6T'></fieldset></dl></div>

                <tbody id='ubw6T'></tbody>
                • 本文介紹了當我將 PyQt QProgressBar 與 Selenuim 一起使用時,它不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我構建了一個 PyQt5 GUI 來進行一些 Selenium 測試.一切都按預期工作,除了 PyQt 進度條.

                  I built a PyQt5 GUI to do some Selenium testing. Everything works as expected, except for the PyQt progress bar.

                  在下面的第一個示例中,我使用 Selenium 瀏覽器,最后,當瀏覽器關閉時,進度條會跳轉到 100%.但是,Selenium 按預期工作.

                  In the first example below, where I use the Selenium browser, the progress bar just jumps to 100%, at the end, when the browser closes. But, the Selenium works as expected.

                  def test(self):
                          self.completed = 0
                          browser = webdriver.Firefox()
                          links = ['http://www.somesite.com/', 'http://www.somesite.com/page2',
                                   'http://www.somesite.com/page3']
                          for link in links:
                              browser.get(link)
                              self.completed += 100 / len(links)
                              time.sleep(2)
                              print(link)
                              self.progressBar.setValue(self.completed)
                          browser.close()
                  

                  但是,在下面的這個版本中,在注釋掉 Selenium 瀏覽器的情況下,進度條按預期工作.

                  But, in this version below, with the Selenium browser commented out, the progress bar works as expected.

                  def test(self):
                          self.completed = 0
                          #browser = webdriver.Firefox()
                          links = ['http://www.somesite.com/', 'http://www.somesite.com/page2',
                                   'http://www.somesite.com/page3']
                          for link in links:
                              #browser.get(link)
                              self.completed += 100 / len(links)
                              time.sleep(2)
                              print(link)
                              self.progressBar.setValue(self.completed)
                          #browser.close()
                  

                  推薦答案

                  阻塞任務對執行 GUI 的事件循環不友好,因為它們阻止了 GUI 執行的正常任務,例如票證檢查、重繪等. 從被處決.

                  The blocking tasks are not friendly with the event loop where the GUI is executed as they prevent the normal tasks that the GUI performs such as ticket checking, redrawing, etc. from being executed.

                  在這些情況下的解決方案是使用線程執行阻塞任務并使用信號發送信息.

                  The solution in these cases is to use thread to execute the blocking task and use the signals to send the information.

                  import sys
                  
                  from PyQt5 import QtCore, QtWidgets
                  
                  from selenium import webdriver
                  
                  class SeleniumWorker(QtCore.QObject):
                      progressChanged = QtCore.pyqtSignal(int)
                      def doWork(self):
                          progress = 0
                          browser = webdriver.Firefox()
                          links = ['http://www.somesite.com/',
                          'http://www.somesite.com/page2',
                          'http://www.somesite.com/page3']
                          for link in links:
                              browser.get(link)
                              progress += 100 / len(links)
                              self.progressChanged.emit(progress)
                          browser.close()
                  
                  class Widget(QtWidgets.QWidget):
                      def __init__(self, *args, **kwargs):
                          QtWidgets.QWidget.__init__(self, *args, **kwargs)
                          lay = QtWidgets.QHBoxLayout(self)
                          progressBar = QtWidgets.QProgressBar()
                          progressBar.setRange(0, 100)
                          button = QtWidgets.QPushButton("Start")
                          lay.addWidget(progressBar)
                          lay.addWidget(button)
                          self.thread = QtCore.QThread()
                          self.worker = SeleniumWorker()
                          self.worker.moveToThread(self.thread)
                          self.thread.started.connect(self.worker.doWork)
                          button.clicked.connect(self.thread.start)
                          self.worker.progressChanged.connect(progressBar.setValue, QtCore.Qt.QueuedConnection)
                  
                  
                  if __name__ == '__main__':
                      app = QtWidgets.QApplication(sys.argv)
                      w = Widget()
                      w.show()
                      sys.exit(app.exec_())
                  

                  這篇關于當我將 PyQt QProgressBar 與 Selenuim 一起使用時,它不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to bind a function to an Action from Qt menubar?(如何將函數綁定到 Qt 菜單欄中的操作?)
                  PyQt progress jumps to 100% after it starts(PyQt 啟動后進度躍升至 100%)
                  How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何將 yaxis 刻度標簽設置在固定位置,以便當我向左或向右滾動時,yaxis 刻度標簽應該可見
                  `QImage` constructor has unknown keyword `data`(`QImage` 構造函數有未知關鍵字 `data`)
                  Change x-axis ticks to custom strings(將 x 軸刻度更改為自定義字符串)
                  How to show progress bar while saving file to excel in python?(如何在python中將文件保存為excel時顯示進度條?)
                    <tbody id='sI23y'></tbody>
                • <tfoot id='sI23y'></tfoot>

                  • <bdo id='sI23y'></bdo><ul id='sI23y'></ul>

                      <legend id='sI23y'><style id='sI23y'><dir id='sI23y'><q id='sI23y'></q></dir></style></legend>
                          • <small id='sI23y'></small><noframes id='sI23y'>

                            <i id='sI23y'><tr id='sI23y'><dt id='sI23y'><q id='sI23y'><span id='sI23y'><b id='sI23y'><form id='sI23y'><ins id='sI23y'></ins><ul id='sI23y'></ul><sub id='sI23y'></sub></form><legend id='sI23y'></legend><bdo id='sI23y'><pre id='sI23y'><center id='sI23y'></center></pre></bdo></b><th id='sI23y'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sI23y'><tfoot id='sI23y'></tfoot><dl id='sI23y'><fieldset id='sI23y'></fieldset></dl></div>
                            主站蜘蛛池模板: 日韩精品a在线观看图片 | 国产精久久久 | 日韩免费福利视频 | 久久国产精品免费一区二区三区 | av中文字幕在线观看 | 欧美一级大片免费看 | 国产第一页在线观看 | 国产xxxx在线 | 日韩一区在线观看视频 | 国内精品久久久久 | 黄片毛片免费看 | 一区二区在线不卡 | 亚洲二区精品 | 99精品视频在线观看免费播放 | 精品美女久久久 | 亚洲一区二区在线电影 | 狠狠色狠狠色综合日日92 | 91久久视频 | 精品欧美乱码久久久久久 | 羞羞涩涩在线观看 | 久久久久久综合 | 亚洲网站在线观看 | 亚洲综合久久网 | 人操人人| 一级做a爰片性色毛片视频停止 | 欧美一级做性受免费大片免费 | 亚洲精品国产电影 | 成人av免费播放 | 九九精品网 | 国产精品免费观看 | 国产视频黄色 | 亚洲电影一区二区三区 | 一区二区在线不卡 | 日日夜精品视频 | www.嫩草| 国产人成精品一区二区三 | 国产精品久久精品 | 巨大荫蒂视频欧美另类大 | 成人免费视频播放 | 美女精品一区 | 成人一区在线观看 |