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

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

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

        <tfoot id='BlnR9'></tfoot>

        如何使用 PyQt5 運行 while 循環

        How I can run while loop with PyQt5(如何使用 PyQt5 運行 while 循環)
      1. <tfoot id='0km7T'></tfoot>
          <i id='0km7T'><tr id='0km7T'><dt id='0km7T'><q id='0km7T'><span id='0km7T'><b id='0km7T'><form id='0km7T'><ins id='0km7T'></ins><ul id='0km7T'></ul><sub id='0km7T'></sub></form><legend id='0km7T'></legend><bdo id='0km7T'><pre id='0km7T'><center id='0km7T'></center></pre></bdo></b><th id='0km7T'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='0km7T'><tfoot id='0km7T'></tfoot><dl id='0km7T'><fieldset id='0km7T'></fieldset></dl></div>

          <small id='0km7T'></small><noframes id='0km7T'>

                <legend id='0km7T'><style id='0km7T'><dir id='0km7T'><q id='0km7T'></q></dir></style></legend>
                  <bdo id='0km7T'></bdo><ul id='0km7T'></ul>
                    <tbody id='0km7T'></tbody>
                  本文介紹了如何使用 PyQt5 運行 while 循環的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在一個項目上工作:程序下載但我在使用 while 循環時遇到問題,用于檢查與 Internet 的連接,如果 true 不 setText('') to lable 和 if Flase setText('anyText') to lable

                  I work on one Project : Program download but I have a problem with while loop for check the connection with the internet and if true doesn't setText('') to lable and if Flase setText('anyText') to lable

                  連接檢查方法

                      def checkInternetConnection(self,host="8.8.8.8", port=53, timeout=3):
                  
                      while self.conection==False:
                          try:
                              socket.setdefaulttimeout(timeout)
                              socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
                              self.conection = True
                              return self.conection
                  
                          except Exception as e:
                                  print(e)
                                  self.label_9.setText('Please Check Internect Connection')
                                  self.conection = False
                                  return self.conection
                      self.finished.emit()
                  

                  我已經厭倦了 QThread .請問我該怎么做:)?如果連接丟失=False setText('check internet') 以及連接變為 true 時,應用程序正在運行時 setText('')

                  I have tired with QThread . Please How I can do it :) ? And when app is running if connection is lost=False setText('check internet') and when the connection become true setText('')

                  構造者

                  From_Class,_=loadUiType(os.path.join(os.path.dirname(__file__),'designe.ui'))
                  class mainApp(QMainWindow,From_Class):
                      finished = pyqtSignal()
                      def __init__(self,parent=None):
                          super(mainApp, self).__init__(parent)
                          QMainWindow.__init__(self)
                          super().setupUi(self)
                          self.handleGui()
                          self.handleButton()
                          self.setWindowIcon(QIcon('mainIcon.png'))
                          self.menuBarW()
                          self.conection = False
                  

                  主代碼

                  def main():
                      app = QApplication(sys.argv)
                      window = mainApp()
                      window.checkInternetConnection()
                      window.show()
                      app.exec()
                  
                  if __name__=='__main__':
                      main()
                  

                  推薦答案

                  QThread不要太復雜,使用線程庫:

                  Do not get complicated with QThread, use the threading library:

                  def main():
                      app = QtWidgets.QApplication(sys.argv)
                      window = mainApp()
                      threading.Thread(target=window.checkInternetConnection, daemon=True).start()
                      window.show()
                      app.exec()
                  

                  另一方面,由于您使用的是線程,因此不應從另一個線程更新 GUI,為此您可以使用 QMetaObject::invokeMethod:

                  On the other hand, since you are using a thread, you should not update the GUI from another thread, for this you can use QMetaObject::invokeMethod:

                  def checkInternetConnection(self,host="8.8.8.8", port=53, timeout=3):
                      while True:
                          try:
                              socket.setdefaulttimeout(timeout)
                              socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect((host, port))
                              self.conection = True
                          except Exception as e:
                              self.conection = False
                              print(e)
                          msg = "" if self.conection else 'Please Check Internect Connection'
                          print("msg", msg)
                          QtCore.QMetaObject.invokeMethod(self.label_9, "setText",
                              QtCore.Qt.QueuedConnection,  
                              QtCore.Q_ARG(str, msg))
                      self.finished.emit()
                  

                  這篇關于如何使用 PyQt5 運行 while 循環的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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時顯示進度條?)

                • <small id='fY71R'></small><noframes id='fY71R'>

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

                    <tbody id='fY71R'></tbody>

                    <tfoot id='fY71R'></tfoot>

                        • <i id='fY71R'><tr id='fY71R'><dt id='fY71R'><q id='fY71R'><span id='fY71R'><b id='fY71R'><form id='fY71R'><ins id='fY71R'></ins><ul id='fY71R'></ul><sub id='fY71R'></sub></form><legend id='fY71R'></legend><bdo id='fY71R'><pre id='fY71R'><center id='fY71R'></center></pre></bdo></b><th id='fY71R'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='fY71R'><tfoot id='fY71R'></tfoot><dl id='fY71R'><fieldset id='fY71R'></fieldset></dl></div>
                          • <bdo id='fY71R'></bdo><ul id='fY71R'></ul>
                            主站蜘蛛池模板: www四虎影视 | 国产精品久久久爽爽爽麻豆色哟哟 | 精品国产一区二区在线 | 亚洲专区在线 | 最新日韩av | 亚洲午夜视频在线观看 | 宅女噜噜66国产精品观看免费 | 91视视频在线观看入口直接观看 | 日本中文字幕日韩精品免费 | 99亚洲精品视频 | 欧美性a视频 | 亚洲一区二区三区免费视频 | 久久久久久一区 | 国产精品免费一区二区三区四区 | 欧美亚洲国产一区二区三区 | 亚洲天堂精品久久 | 国产精品福利网站 | 日韩精品免费视频 | 毛片一级片 | 国产成人免费视频网站视频社区 | 国产毛片久久久 | 亚洲精品电影在线观看 | 精品国产一区二区三区免费 | 黑人精品欧美一区二区蜜桃 | 久久久久久久久久久成人 | 久久综合99 | 国产精品一区二区三区99 | 日韩精品国产精品 | 精品日韩 | 国产视频久久久 | 免费观看的黄色网址 | 国产亚洲欧美在线 | 国产二区视频 | 日韩免费毛片视频 | 天堂一区二区三区 | 男女羞羞视频在线观看 | 一级看片免费视频囗交动图 | 草久久| 一级免费在线视频 | 日日操日日干 | 日日操日日舔 |