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

  • <tfoot id='nmDJk'></tfoot>

          <bdo id='nmDJk'></bdo><ul id='nmDJk'></ul>
      1. <small id='nmDJk'></small><noframes id='nmDJk'>

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

        <legend id='nmDJk'><style id='nmDJk'><dir id='nmDJk'><q id='nmDJk'></q></dir></style></legend>

        我如何用 pafy 為進度條制作線程

        how i can make thread for progress bar with pafy(我如何用 pafy 為進度條制作線程)
        <tfoot id='4PaxF'></tfoot>
          • <bdo id='4PaxF'></bdo><ul id='4PaxF'></ul>
              <tbody id='4PaxF'></tbody>

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

                1. 本文介紹了我如何用 pafy 為進度條制作線程的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試解決我的程序中的問題,這個問題是當我開始下載視頻時,程序沒有響應,我也看不到進度條移動,所以我嘗試使用線程模塊,但我無法解決問題所以我該如何解決問題

                  i'm trying to fix problem in my program and this problem is when i start download video the program not responding and i can't see also progress bar move so i tried used threading module but i can't fix problem so how i can fix problem

                  通過此代碼,我可以下載視頻并將數據發送到另一個函數,以檢索我用來將其連接到進度條的信息

                  From this code I can download the video and send the data to another function to retrieve information that I use to connect it to the progress bar

                  def video(self):
                      video_url = self.lineEdit_4.text()
                      video_save = self.lineEdit_3.text()
                  
                      pafy_video = pafy.new(video_url)
                      type_video = pafy_video.videostreams
                  
                      quality = self.comboBox.currentIndex()
                  
                      start_download = type_video[quality].download(filepath=video_save,callback=self.video_progressbar)
                  

                  此代碼是從視頻功能接收信息以連接進度條

                  This code is received information from video function to connect with progress bar

                  def video_progressbar(self,total, recvd, ratio, rate, eta):
                      self.progressBar_2.setValue(ratio * 100)
                  

                  我用;python3.5 pyqt5 pafy

                  I use;python3.5 pyqt5 pafy

                  推薦答案

                  移動到另一個線程的一種方法是創建一個存在于另一個線程中的 QObject 并在插槽中執行該任務.并且該槽必須通過 QMetaObject::invokeMethod 或信號調用.

                  One way to move to another thread is to create a QObject that lives in another thread and execute that task in a slot. And that slot must be invoked through QMetaObject::invokeMethod or a signal.

                  import pafy
                  from PyQt5 import QtCore, QtWidgets
                  
                  class MainWindow(QtWidgets.QMainWindow):
                      def __init__(self, parent=None):
                          super(MainWindow, self).__init__(parent)
                          central_widget = QtWidgets.QWidget()
                          self.setCentralWidget(central_widget)
                  
                          self.le_url = QtWidgets.QLineEdit("https://www.youtube.com/watch?v=bMt47wvK6u0")
                          path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.DownloadLocation)
                          self.le_output = QtWidgets.QLineEdit(path)
                          self.btn_quality = QtWidgets.QPushButton("Get qualities")
                          self.combo_quality = QtWidgets.QComboBox()
                          self.btn_download = QtWidgets.QPushButton("Download")
                          self.progressbar = QtWidgets.QProgressBar(maximum=100)
                  
                          self.downloader = DownLoader()
                          thread = QtCore.QThread(self)
                          thread.start()
                          self.downloader.moveToThread(thread)
                  
                          self.btn_quality.clicked.connect(self.on_clicked_quality)
                          self.btn_download.clicked.connect(self.download)
                          self.btn_download.setDisabled(True)
                          self.downloader.progressChanged.connect(self.progressbar.setValue)
                          self.downloader.qualitiesChanged.connect(self.update_qualityes)
                          self.downloader.finished.connect(self.on_finished)
                  
                          form_lay = QtWidgets.QFormLayout(central_widget)
                          form_lay.addRow("Url: ", self.le_url)
                          form_lay.addRow(self.btn_quality)
                          form_lay.addRow("qualities: ", self.combo_quality)
                          form_lay.addRow("Output: ", self.le_output) 
                          form_lay.addRow(self.btn_download)  
                          form_lay.addRow(self.progressbar)
                  
                      @QtCore.pyqtSlot()
                      def on_finished(self):
                          self.update_disables(False)
                  
                      @QtCore.pyqtSlot()
                      def on_clicked_quality(self):
                          video_url = self.le_url.text()
                          QtCore.QMetaObject.invokeMethod(self.downloader, "get_qualities",
                              QtCore.Qt.QueuedConnection,
                              QtCore.Q_ARG(str, video_url))
                  
                      @QtCore.pyqtSlot(list)
                      def update_qualityes(self, types_of_video):
                          for t in types_of_video:
                              self.combo_quality.addItem(str(t), t)
                          self.btn_download.setDisabled(False)
                  
                      @QtCore.pyqtSlot()
                      def download(self):
                          video_save = self.le_output.text()
                          d = self.combo_quality.currentData()
                          QtCore.QMetaObject.invokeMethod(self.downloader, "start_download",
                              QtCore.Qt.QueuedConnection,
                              QtCore.Q_ARG(object, d),
                              QtCore.Q_ARG(str, video_save))
                          self.update_disables(True)
                  
                      def update_disables(self, state):
                          self.combo_quality.setDisabled(state)
                          self.btn_quality.setDisabled(state)
                          self.le_output.setDisabled(state)
                          self.le_url.setDisabled(state)
                          self.btn_download.setDisabled(not state)
                  
                  class DownLoader(QtCore.QObject):
                      progressChanged = QtCore.pyqtSignal(int)
                      qualitiesChanged = QtCore.pyqtSignal(list)
                      finished = QtCore.pyqtSignal()
                  
                      @QtCore.pyqtSlot(str)
                      def get_qualities(self, video_url):
                          pafy_video = pafy.new(video_url)
                          types_of_video = pafy_video.allstreams # videostreams
                          self.qualitiesChanged.emit(types_of_video)
                  
                      @QtCore.pyqtSlot(object, str)
                      def start_download(self, d, filepath):
                          d.download(filepath=filepath, callback=self.callback)
                  
                      def callback(self, total, recvd, ratio, rate, eta):
                          val = int(ratio * 100)
                          self.progressChanged.emit(val)
                          if val == 100:
                              self.finished.emit()
                  
                  if __name__ == '__main__':
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      w = MainWindow()
                      w.resize(320, 480)
                      w.show()
                      sys.exit(app.exec_())
                  

                  with threading.Thread:

                  import pafy
                  import threading
                  from PyQt5 import QtCore, QtWidgets
                  
                  class MainWindow(QtWidgets.QMainWindow):
                      qualitiesChanged = QtCore.pyqtSignal(list)
                      progressChanged = QtCore.pyqtSignal(int)
                      finished = QtCore.pyqtSignal()
                  
                      def __init__(self, parent=None):
                          super(MainWindow, self).__init__(parent)
                          central_widget = QtWidgets.QWidget()
                          self.setCentralWidget(central_widget)
                  
                          self.le_url = QtWidgets.QLineEdit("https://www.youtube.com/watch?v=bMt47wvK6u0")
                          path = QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.DownloadLocation)
                          self.le_output = QtWidgets.QLineEdit(path)
                          self.btn_quality = QtWidgets.QPushButton("Get qualities")
                          self.combo_quality = QtWidgets.QComboBox()
                          self.btn_download = QtWidgets.QPushButton("Download")
                          self.progressbar = QtWidgets.QProgressBar(maximum=100)
                  
                          self.btn_quality.clicked.connect(self.on_clicked_quality)
                          self.btn_download.clicked.connect(self.download)
                          self.btn_download.setDisabled(True)
                          self.progressChanged.connect(self.progressbar.setValue)
                          self.qualitiesChanged.connect(self.update_qualityes)
                          self.finished.connect(self.on_finished)
                  
                          form_lay = QtWidgets.QFormLayout(central_widget)
                          form_lay.addRow("Url: ", self.le_url)
                          form_lay.addRow(self.btn_quality)
                          form_lay.addRow("qualities: ", self.combo_quality)
                          form_lay.addRow("Output: ", self.le_output) 
                          form_lay.addRow(self.btn_download)  
                          form_lay.addRow(self.progressbar)
                  
                      @QtCore.pyqtSlot()
                      def on_finished(self):
                          self.update_disables(False)
                  
                      @QtCore.pyqtSlot()
                      def on_clicked_quality(self):
                          video_url = self.le_url.text()
                          threading.Thread(target=self.get_qualities, args=(video_url,)).start()
                  
                      def get_qualities(self, video_url):
                          pafy_video = pafy.new(video_url)
                          types_of_video = pafy_video.allstreams # videostreams
                          self.qualitiesChanged.emit(types_of_video)
                  
                      @QtCore.pyqtSlot(list)
                      def update_qualityes(self, types_of_video):
                          for t in types_of_video:
                              self.combo_quality.addItem(str(t), t)
                          self.btn_download.setDisabled(False)
                  
                      @QtCore.pyqtSlot()
                      def download(self):
                          video_save = self.le_output.text()
                          d = self.combo_quality.currentData()
                          threading.Thread(target=d.download, kwargs={'filepath': video_save, 'callback': self.callback}, daemon=True).start()
                  
                      def callback(self, total, recvd, ratio, rate, eta):
                          print(ratio)
                          val = int(ratio * 100)
                          self.progressChanged.emit(val)
                          if val == 100:
                              self.finished.emit()
                  
                      def update_disables(self, state):
                          self.combo_quality.setDisabled(state)
                          self.btn_quality.setDisabled(state)
                          self.le_output.setDisabled(state)
                          self.le_url.setDisabled(state)
                          self.btn_download.setDisabled(not state)
                  
                  if __name__ == '__main__':
                      import sys
                      app = QtWidgets.QApplication(sys.argv)
                      w = MainWindow()
                      w.resize(320, 480)
                      w.show()
                      sys.exit(app.exec_())
                  

                  這篇關于我如何用 pafy 為進度條制作線程的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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時顯示進度條?)
                  <legend id='26oP6'><style id='26oP6'><dir id='26oP6'><q id='26oP6'></q></dir></style></legend>
                2. <tfoot id='26oP6'></tfoot>

                        <small id='26oP6'></small><noframes id='26oP6'>

                          <tbody id='26oP6'></tbody>

                          <bdo id='26oP6'></bdo><ul id='26oP6'></ul>

                          1. <i id='26oP6'><tr id='26oP6'><dt id='26oP6'><q id='26oP6'><span id='26oP6'><b id='26oP6'><form id='26oP6'><ins id='26oP6'></ins><ul id='26oP6'></ul><sub id='26oP6'></sub></form><legend id='26oP6'></legend><bdo id='26oP6'><pre id='26oP6'><center id='26oP6'></center></pre></bdo></b><th id='26oP6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='26oP6'><tfoot id='26oP6'></tfoot><dl id='26oP6'><fieldset id='26oP6'></fieldset></dl></div>
                            主站蜘蛛池模板: 香蕉久久av | 国产精品视频一区二区三区不卡 | 日本成人福利 | 一区二区免费 | 久久久久一区二区三区四区 | 日韩精品视频一区二区三区 | 午夜精品一区二区三区在线视频 | 精品在线一区二区三区 | 午夜精品一区二区三区在线视频 | 国产一区二区免费 | 成人h动漫精品一区二区器材 | 国产精品美女久久久av超清 | 欧美性受xxxx | 神马久久久久久久久久 | 日韩中文一区二区 | 国产精品一区久久久 | av毛片免费 | 奇米视频777 | 狠狠操狠狠干 | 日韩免费福利视频 | 日韩精品一区二区三区中文在线 | 久久色视频 | 亚洲成av人影片在线观看 | 一区二区在线不卡 | 亚洲福利 | 午夜免费视频 | 中文字幕一区二区三区乱码图片 | 亚洲国产高清高潮精品美女 | 日韩在线欧美 | 免费特黄视频 | 无码一区二区三区视频 | 久久久www成人免费无遮挡大片 | 成年网站在线观看 | 久久国产婷婷国产香蕉 | 欧美一级片在线 | 午夜精品一区二区三区免费视频 | 天天操天天射综合 | 91精品国产91久久综合桃花 | 久久久免费电影 | 日日爽| 国产一区二区在线播放 |