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

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

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

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

        PyQt5 QLCNumber 沒有更新

        PyQt5 The QLCNumber doesnt update(PyQt5 QLCNumber 沒有更新)
      1. <small id='KR5NM'></small><noframes id='KR5NM'>

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

                  <tbody id='KR5NM'></tbody>

                • <legend id='KR5NM'><style id='KR5NM'><dir id='KR5NM'><q id='KR5NM'></q></dir></style></legend>
                  本文介紹了PyQt5 QLCNumber 沒有更新的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想制作一個計算脈沖的程序,然后它會通過一些方程式并將其顯示在 gui 中.這是我的 main.py

                  i want to make a program that count pulses then it go through some equation and display it in the gui . This my main.py

                  import sys
                  import time
                  import RPi.GPIO as GPIO
                  import PyQt5
                  from PyQt5.QtWidgets import *
                  from PyQt5.QtCore import *
                  from mainwindow import Ui_MainWindow
                  GPIO.setmode(GPIO.BCM)
                  GPIO.setup(18, GPIO.IN, pull_up_down = GPIO.PUD_UP)
                   
                  class MainWindow(QMainWindow):
                   # access variables inside of the UI's file
                   def __init__(self):
                       super().__init__()
                       self.mainwindow = Ui_MainWindow()
                       self.mainwindow.setupUi(self)
                       self.i=100
                       self.flow = 0
                       self.flowliter = 0
                       self.totalflow=0
                  
                       
                       self.mainwindow.lcdNumber.display(self.i)
                       self.mainwindow.lcdNumber_2.display(self.i)  
                       self.show()
                       
                   
                       self.mainwindow.startbttn.clicked.connect(lambda: self.pressedstartButton())
                       self.mainwindow.stopbttn.clicked.connect(lambda: self.pressedstopButton())
                       
                   
                   def pressedstartButton(self):
                       print ("Pressed On!")
                       self.data()
                   
                   def pressedstopButton(self):
                       print ("Pressed Off!")
                       
                   def data(self) :
                       global count
                       count = 0
                  
                       def countPulse(channel):
                        global count
                        if start_counter == 1:
                            count = count+1
                  
                       GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback=countPulse)
                  
                       while True:
                          try:
                           start_counter = 1
                           time.sleep(1)
                           start_counter = 4
                  
                           self.flow = (10 * 60)
                           self.flowliter= (self.flow/60)
                           self.totalflow += self.flowliter
                           print("%d"% (count))
                           print ("The flow is: %.3f Liter/min" % (self.flow))
                           print ("The flowliter is: %.3f Liter" % (self.flowliter))
                           print ("The volume is: %.3f Liter" % (self.totalflow))
                           self.mainwindow.lcdNumber.display(self.flow)
                           self.mainwindow.lcdNumber_2.display(self.flowliter)
                           count = 0
                           time.sleep(1)
                          except KeyboardInterrupt:
                           print ('
                  caught keyboard interrupt!, bye')
                           GPIO.cleanup()
                           sys.exit()
                  
                  
                  def main():
                       app = QApplication(sys.argv)
                       form = MainWindow()
                       form.show()
                       sys.exit(app.exec_())
                   
                  if __name__ == "__main__":
                      main()
                  
                  

                  lcdnumber 在 gui 中沒有更新,但 shell 中的 self.flow 更新,我想顯示值在 gui 中,但我不知道哪一個適合 qtablewidget 或 qtextbroswer此代碼應計算來自 gpio 18 的脈沖并在 gui 中顯示流程.

                  the lcdnumber doesnt update in the gui but the self.flow update in the shell and i want display the value in the gui but i dont know which one suitable qtablewidget or qtextbroswer this code should count the pulse from the gpio 18 and show the flow in the gui.

                  推薦答案

                  你不應該使用耗時的函數,因為它們會阻塞事件循環,結果是凍結 GUI.在這種情況下,您不應該使用無限循環或 time.sleep,但 QTimer 就足夠了.

                  You should not use time-consuming functions as they block the eventloop and the consequence is to freeze the GUI. In this case, you should not use an infinite loop or time.sleep but a QTimer is enough.

                  import sys
                  import RPi.GPIO as GPIO
                  
                  from PyQt5.QtWidgets import *
                  from PyQt5.QtCore import *
                  
                  from mainwindow import Ui_MainWindow
                  
                  
                  FLOW_SENSOR = 18
                  
                  
                  class MainWindow(QMainWindow):
                      pinSignal = pyqtSignal()
                  
                      def __init__(self):
                          super().__init__()
                          self.mainwindow = Ui_MainWindow()
                          self.mainwindow.setupUi(self)
                          self.i = 100
                          self.flow = 0
                          self.flowliter = 0
                          self.totalflow = 0
                  
                          self.mainwindow.lcdNumber.display(self.i)
                          self.mainwindow.lcdNumber_2.display(self.i)
                          self.show()
                  
                          self.mainwindow.startbttn.clicked.connect(self.pressedstartButton)
                          self.mainwindow.stopbttn.clicked.connect(self.pressedstopButton)
                  
                          self.start_counter = False
                          self.count = 0
                  
                          self.timer = QTimer(self, interval=1000, timeout=self.execute_every_second)
                          self.pinSignal.connect(self.handle_pin_signal)
                  
                      def pressedstartButton(self):
                          print("Pressed On!")
                          GPIO.add_event_detect(FLOW_SENSOR, GPIO.FALLING, callback = lambda *args: self.pinSignal.emit())
                          self.execute_every_second()
                          self.timer.start()
                  
                      def pressedstopButton(self):
                          print("Pressed Off!")
                          self.timer.stop()
                          GPIO.remove_event_detect(FLOW_SENSOR)
                  
                      def handle_pin_signal(self):
                          if self.start_counter:
                              self.count += 1
                  
                      def execute_every_second(self):
                          if not self.start_counter:
                              self.flow = 10 * 60
                              self.flowliter = self.flow / 60
                              self.totalflow += self.flowliter
                              print("%d" % (self.count))
                              print("The flow is: %.3f Liter/min" % (self.flow))
                              print("The flowliter is: %.3f Liter" % (self.flowliter))
                              print("The volume is: %.3f Liter" % (self.totalflow))
                              self.mainwindow.lcdNumber.display(self.flow)
                              self.mainwindow.lcdNumber_2.display(self.flowliter)
                              self.count = 0
                          self.start_counter = not self.start_counter
                  
                  
                  def main():
                      GPIO.setmode(GPIO.BCM)
                      GPIO.setup(FLOW_SENSOR, GPIO.IN, pull_up_down=GPIO.PUD_UP)
                  
                      app = QApplication(sys.argv)
                      form = MainWindow()
                      form.show()
                      ret = app.exec_()
                  
                      GPIO.cleanup()
                  
                      sys.exit(ret)
                  
                  
                  if __name__ == "__main__":
                      main()
                  

                  這篇關于PyQt5 QLCNumber 沒有更新的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='q6Im1'><style id='q6Im1'><dir id='q6Im1'><q id='q6Im1'></q></dir></style></legend>

                          <bdo id='q6Im1'></bdo><ul id='q6Im1'></ul>

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

                            主站蜘蛛池模板: 国产精品久久久久久久久久 | 精品国产精品一区二区夜夜嗨 | 日韩高清一区 | 欧美午夜在线 | 成年人免费看 | 亚洲精品一区中文字幕乱码 | 成人免费av在线 | 免费一看一级毛片 | 久久国产日韩欧美 | 99福利| 午夜一区 | 在线国产一区二区 | 亚洲欧美一区在线 | 日韩在线播放一区 | 国产亚洲一区精品 | 欧美性视频在线播放 | 国产成人99久久亚洲综合精品 | 欧美另类视频在线 | 久久精品91久久久久久再现 | 中文字幕91av | 午夜电影网站 | 亚洲精品日韩一区二区电影 | 午夜在线免费观看视频 | 欧美一区二区三区在线观看视频 | 欧美性a视频 | 国产三级精品视频 | 国产精品国产a级 | 国产精品高潮呻吟久久久久 | 国产一区在线免费观看 | 97精品国产97久久久久久免费 | 免费一二区 | 久久一区 | 国产成年人小视频 | 一区影视| 男女羞羞视频免费看 | 成人精品鲁一区一区二区 | 日本久久久久久久久 | 日韩精品一区二区三区中文字幕 | 一区二区三区在线免费观看 | 国产精品久久久久久久久久久久冷 | 亚洲一区二区三区免费观看 |