1
我写了一个Python 3.4的代码,它使用PyQt4的GUI模块,但是Python PyQt的界面代码当我运行它不会显示任何模块好心帮没有运行
import sys
from PyQt4 import QtGui,QtCore
class window(QtGui.QMainWindow):
def _init_(self):
super(Window, self)._init_()
self.setGeometry(50,50,500,300)
self.setWindowTitle("Tallman Server")
self.setWindowIcon(QtGui.QIcon("tracking.png"))
self.home()
def home():
btn=QtGui.QPushButton("Quit",self)
btn.clicked.connect(QtCore.QCoreApplication.instance().quit)
self.show()
def run():
app=QtGui.QApplication(sys.argv)
GUI=window()
sys.exit(app.exec_())
run()
感谢很大的帮助我在PyQt的尼夫新认识的小错误可能使程序无法正常工作。 – tallman
@tallman:'__init__'和'self'是python面向对象特性的一部分,与'pyqt'无关。我建议你让自己熟悉课程,例如[本文档](https://docs.python.org/2/tutorial/classes.html#class-objects)对其进行了解释。否则,你将在未来遇到类似的问题 – hansaplast