我开始学习使用 PyQt4。我有一个想要显示的简单 gui 窗口(没什么花哨的)。
这是代码:
import sys
from PyQt4 import QtGui
from test import Ui_MainWindow
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())
但是eclipse给了我以下错误:
TypeError: unbound method setupUi() must be called with Ui_MainWindow instance
as first argument (got MyForm instance instead)
有什么建议么?