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

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

        <bdo id='BAS2h'></bdo><ul id='BAS2h'></ul>
      <legend id='BAS2h'><style id='BAS2h'><dir id='BAS2h'><q id='BAS2h'></q></dir></style></legend>
      1. <tfoot id='BAS2h'></tfoot>

        PyQt5 按鈕運行功能和更新 LCD

        PyQt5 button to run function and update LCD(PyQt5 按鈕運行功能和更新 LCD)
        1. <small id='E0OmW'></small><noframes id='E0OmW'>

            <tfoot id='E0OmW'></tfoot>

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

                  本文介紹了PyQt5 按鈕運行功能和更新 LCD的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我開始使用 Python 3 在 PyQt5 中創建 GUI.單擊按鈕時,我想運行randomint"函數并將返回的整數顯示到名為lcd"的 QLCDNumber.

                  I am getting started with creating GUI's in PyQt5 with Python 3. At the click of the button I want to run the "randomint" function and display the returned integer to the QLCDNumber named "lcd".

                  這是我的代碼:

                  import sys
                  from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLCDNumber
                  from random import randint
                  
                  
                  class Window(QWidget):
                      def __init__(self):
                          super().__init__()
                          self.initui()
                  
                      def initui(self):
                          lcd = QLCDNumber(self)
                  
                          button = QPushButton('Generate', self)
                          button.resize(button.sizeHint())
                  
                          layout = QVBoxLayout()
                          layout.addWidget(lcd)
                          layout.addWidget(button)
                  
                          self.setLayout(layout)
                          button.clicked.connect(lcd.display(self.randomint()))
                  
                          self.setGeometry(300, 500, 250, 150)
                          self.setWindowTitle('Rand Integer')
                          self.show()
                  
                      def randomint(self):
                          random = randint(2, 99)
                          return random
                  
                  if __name__ == '__main__':
                      app = QApplication(sys.argv)
                      ex = Window()
                      sys.exit(app.exec_())
                  

                  我得到了輸出:

                  TypeError:參數 1 具有意外類型NoneType"

                  TypeError: argument 1 has unexpected type 'NoneType'

                  如何讓 LCD 顯示函數randomint"的輸出?

                  How can I get the LCD to display the output from function "randomint"?

                  推薦答案

                  問題是 button.clicked.connect 需要 slot(Python 可調用對象),但是 lcd.display 返回 .所以我們需要一個簡單的 button.clicked.connect 函數(槽)來顯示你新生成的值.這是工作版本:

                  The problem is that the button.clicked.connect expects the slot (Python callable object), but lcd.display returns None. So we need a simple function (slot) for button.clicked.connect which will display your newly generated value. This is working version:

                  import sys
                  from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton, QLCDNumber
                  from random import randint
                  
                  
                  class Window(QWidget):
                      def __init__(self):
                          super().__init__()
                          self.initui()
                  
                  
                      def initui(self):
                          self.lcd = QLCDNumber(self)
                  
                          button = QPushButton('Generate', self)
                          button.resize(button.sizeHint())
                  
                          layout = QVBoxLayout()
                          layout.addWidget(self.lcd)
                          layout.addWidget(button)
                  
                          self.setLayout(layout)
                          button.clicked.connect(self.handleButton)
                  
                          self.setGeometry(300, 500, 250, 150)
                          self.setWindowTitle('Rand Integer')
                          self.show()
                  
                  
                      def handleButton(self):
                          self.lcd.display(self.randomint())
                  
                  
                      def randomint(self):
                          random = randint(2, 99)
                          return random
                  
                  
                  if __name__ == '__main__':
                  
                      app = QApplication(sys.argv)
                      ex = Window()
                      sys.exit(app.exec_())
                  

                  這篇關于PyQt5 按鈕運行功能和更新 LCD的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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時顯示進度條?)

                1. <legend id='QVSF4'><style id='QVSF4'><dir id='QVSF4'><q id='QVSF4'></q></dir></style></legend>
                2. <small id='QVSF4'></small><noframes id='QVSF4'>

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

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

                            主站蜘蛛池模板: 中文字幕免费在线 | 亚洲精品视频一区 | 日本成人中文字幕 | 欧美一页 | 91毛片在线看 | 亚洲精品免费视频 | 欧美人妇做爰xxxⅹ性高电影 | 91观看| 岛国av免费在线观看 | 欧美亚洲在线视频 | 欧美日韩专区 | 九九热在线视频观看这里只有精品 | 日本黄色影片在线观看 | 九九热在线精品视频 | 精国产品一区二区三区 | 亚洲成av人片在线观看 | 黄色在线播放视频 | 国产精品视频网址 | 在线免费av电影 | 一级高清 | 久久黄色 | 亚洲精品一区二区三区丝袜 | 精品国产乱码久久久久久丨区2区 | av电影手机版 | 国产欧美一区二区三区久久 | 日韩电影免费在线观看中文字幕 | 亚洲国产aⅴ成人精品无吗 欧美激情欧美激情在线五月 | 天天干成人网 | 亚洲电影第三页 | 亚洲一区国产精品 | 做a视频| 午夜国产精品视频 | 国产精品视频一区二区三区 | 午夜视频大全 | 一区二区三区亚洲 | 欧美日韩精品一区二区三区视频 | 亚洲视频一区在线播放 | 精品国产伦一区二区三区观看体验 | 在线欧美亚洲 | 国产精品免费一区二区三区 | 午夜影院视频在线观看 |