80,471
社区成员




class MyCalc(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# make elements
buttons = ["0", "1", "2", "3", "4", "5", "6",
"7", "8", "9", ".", "+", "-", "*", "/"]
position = [(i,j) for i in range(5) for j in range(4)]
layout = QGridLayout()
for pos,name in zip(position,buttons):
button = QPushButton(name)
layout.addWidget(button, *pos)
self.move(300, 150)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MyCalc()
sys.exit(app.exec_())
button = QPushButton(name, self)