久久久久久久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>

                            主站蜘蛛池模板: 久久国内精品 | 午夜不卡一区二区 | 久久中文字幕电影 | 天天天天天天操 | 精品不卡 | 91av免费看| 国产午夜精品一区二区三区嫩草 | 国产一区二区三区在线看 | 精品美女在线观看视频在线观看 | 亚洲久久一区 | 久久国产综合 | 在线一区| 久久久久久高潮国产精品视 | 欧洲一区二区三区 | 久久精品视频在线播放 | 国产一区二区激情视频 | 色888www视频在线观看 | 人人做人人澡人人爽欧美 | 精品一区二区三区四区五区 | 亚洲永久精品国产 | 中文字幕成人 | 狠狠躁躁夜夜躁波多野结依 | 久久精品一区二区 | 国产免费观看一级国产 | 99久久精品免费看国产免费软件 | 色网站在线免费观看 | 国产成人免费一区二区60岁 | 欧美 日韩 亚洲91麻豆精品 | 色毛片 | 一区二区三区中文字幕 | 午夜精品一区二区三区在线播放 | 成人精品国产免费网站 | 欧美日韩在线一区二区 | 欧洲一级毛片 | 99re在线视频| 国产一区二区三区四区五区加勒比 | 欧美一区二区三区四区在线 | 国产91视频一区二区 | 欧美精品在线播放 | 久久久国产精品入口麻豆 | 国产乡下妇女做爰 |