请有人告诉我为什么这段代码似乎确实有效。那就是至少显示一个对话框。
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class Form(QDialog):
def _init_(self,parent = None):
super(Form , self).__init__(parent)
self.numberLabel1 = QLabel("first Number")
self.numberLabel2 = QLabel("Second Number")
self.txtField1 = QLineEdit()
self.txtField2 = QLineEdit()
self.btnSum = QPushButton("Sum")
self.resultKeep = QLabel()
grid = QGridLayout()
grid.addWidget(self.numberLabel1,0,0)
grid.addWidget(self.txtField1,0,1)
grid.addWidget(self.numberLabel2,1,0)
grid.addWidget(self.txtField2,1,1)
grid.addWidget(self.resultKeep,0,2)
grid.addWidget(self.btnSum,0,3)
self.setLayout(grid)
if __name__ == '__init__' :
app = QApplication(sys.a`enter code here`rgv)
form = Form()
form.show()
#sys.exit(app.exec_())