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

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

        参数 1 有意外的类型“NoneType"?

        时间:2023-08-06

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

          • <bdo id='aApCj'></bdo><ul id='aApCj'></ul>

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

            <legend id='aApCj'><style id='aApCj'><dir id='aApCj'><q id='aApCj'></q></dir></style></legend>
                  <tbody id='aApCj'></tbody>
              • <tfoot id='aApCj'></tfoot>

                  本文介绍了参数 1 有意外的类型“NoneType"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的 PyQt 按钮操作有问题.我想发送一个带有函数的字符串,但我收到了这个错误:

                  I have a problem with my PyQt button action. I would like to send a String with the Function but I got this Error:

                  TypeError:参数 1 具有意外类型NoneType"

                  TypeError: argument 1 has unexpected type 'NoneType'

                  import sys
                  
                  from PyQt5.QtWidgets import QApplication, QPushButton, QAction
                  from PyQt5.QtCore import QObject, pyqtSignal
                  from PyQt5.QtGui import *
                  from PyQt5.uic import *
                  
                  app = QApplication(sys.argv)
                  cocktail = loadUi('create.ui')
                  
                  def mixCocktail(str):
                        cocktail.show()
                        cocktail.showFullScreen()
                        cocktail.lbl_header.setText(str)
                  
                  
                  widget = loadUi('drinkmixer.ui')
                  
                  widget.btn_ckt1.clicked.connect(mixCocktail("string"))
                  
                  widget.show()
                  sys.exit(app.exec_())
                  

                  推荐答案

                  根据 user3030010 和 ekhumoro 它需要一个可调用的函数.在这种情况下,您应该将该参数替换为 lambda: mixCocktail("string")AND ALSO 不要使用 str 它是 python 内置数据类型,我已将其替换为 _str

                  As suggested by user3030010 and ekhumoro it expects a callable function. In which case you should replace that argument with lambda: mixCocktail("string") AND ALSO don't use str it's a python built-in datatype I have replaced it with _str

                  import sys
                  
                  from PyQt5.QtWidgets import QApplication, QPushButton, QAction
                  from PyQt5.QtCore import QObject, pyqtSignal
                  from PyQt5.QtGui import *
                  from PyQt5.uic import *
                  
                  app = QApplication(sys.argv)
                  cocktail = loadUi('create.ui')
                  
                  def mixCocktail(_str):
                        cocktail.show()
                        cocktail.showFullScreen()
                        cocktail.lbl_header.setText(_str)
                        
                  
                  widget = loadUi('drinkmixer.ui')
                  
                  widget.btn_ckt1.clicked.connect(lambda: mixCocktail("string"))
                  
                  widget.show()
                  sys.exit(app.exec_())
                  

                  关于 lambda 函数的更多信息:什么是 lambda(函数)?

                  More about lambda functions: What is a lambda (function)?

                  这篇关于参数 1 有意外的类型“NoneType"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:通过 connect 传递额外的参数 下一篇:当我将 PyQt QProgressBar 与 Selenuim 一起使用时,它不

                  相关文章

                  最新文章

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

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

                1. <small id='KF3Nb'></small><noframes id='KF3Nb'>

                    <tfoot id='KF3Nb'></tfoot>