How to rectify the python error: "icon object is not callable"?
How to rectify the python error: "icon object is not callable"?
我有一本字典,其中包含某些元素和关联的键。我想创建一个 GUI 来显示项目。我在 for 循环中使用了 QMessageBox PyQt 小部件。但是当我 运行 代码时,我收到以下错误:
回溯(最近一次调用最后一次):文件 "C:\Python34_64bit\dictt.py",第 50 行,在 main() 文件中 "C:\Python34_64bit\dictt.py",第 45 行,在主 GUI=MYGUI() 文件中"C:\Python34_64bit\dictt.py",第 31 行,在初始化 self.Choice=QtGui.QMessageBox.Question(self,k,val,QtGui.QMes sageBox.Yes | QtGui.QMessageBox.No ) TypeError: 'Icon' 对象不可调用
请帮助我如何通过修改我的代码来解决这个问题。下面是我的代码:
import sys
from PyQt4 import QtGui,QtCore
class MYGUI(QtGui.QWidget):
def __init__(self):
super(MYGUI,self).__init__()
self.setWindowTitle("GUI")
#widgets:
self.labl=QtGui.QLabel(self)
self.labl.setFont(QtGui.QFont('Calibri', 34))
#Layout:
Layout =QtGui.QVBoxLayout()
Layout.addWidget(self.labl)
Layout.addStretch()
self.setLayout(Layout)
#Actions:
Queries={'Q1':'question 1','Q2':'question2'}
for k,val in Queries.items():
self.Choice=QtGui.QMessageBox.Question(self,k,val,QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice==QtGui.QMessageBox.Yes:
self.labl.setText('yes')
else:
self.labl.setText('No')
self.show()
def main():
app=QtGui.QApplication(sys.argv)
GUI=MYGUI()
sys.exit(app.exec_())
main()
你的问题只是 lower/upper 个案例。
QMessageBox.Question
是图标
QMessageBox.question(parent, title, text, button0, button1)
是函数
参见:https://srinikom.github.io/pyside-docs/PySide/QtGui/QMessageBox.html
我有一本字典,其中包含某些元素和关联的键。我想创建一个 GUI 来显示项目。我在 for 循环中使用了 QMessageBox PyQt 小部件。但是当我 运行 代码时,我收到以下错误:
回溯(最近一次调用最后一次):文件 "C:\Python34_64bit\dictt.py",第 50 行,在 main() 文件中 "C:\Python34_64bit\dictt.py",第 45 行,在主 GUI=MYGUI() 文件中"C:\Python34_64bit\dictt.py",第 31 行,在初始化 self.Choice=QtGui.QMessageBox.Question(self,k,val,QtGui.QMes sageBox.Yes | QtGui.QMessageBox.No ) TypeError: 'Icon' 对象不可调用
请帮助我如何通过修改我的代码来解决这个问题。下面是我的代码:
import sys
from PyQt4 import QtGui,QtCore
class MYGUI(QtGui.QWidget):
def __init__(self):
super(MYGUI,self).__init__()
self.setWindowTitle("GUI")
#widgets:
self.labl=QtGui.QLabel(self)
self.labl.setFont(QtGui.QFont('Calibri', 34))
#Layout:
Layout =QtGui.QVBoxLayout()
Layout.addWidget(self.labl)
Layout.addStretch()
self.setLayout(Layout)
#Actions:
Queries={'Q1':'question 1','Q2':'question2'}
for k,val in Queries.items():
self.Choice=QtGui.QMessageBox.Question(self,k,val,QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice==QtGui.QMessageBox.Yes:
self.labl.setText('yes')
else:
self.labl.setText('No')
self.show()
def main():
app=QtGui.QApplication(sys.argv)
GUI=MYGUI()
sys.exit(app.exec_())
main()
你的问题只是 lower/upper 个案例。
QMessageBox.Question
是图标
QMessageBox.question(parent, title, text, button0, button1)
是函数
参见:https://srinikom.github.io/pyside-docs/PySide/QtGui/QMessageBox.html