通过编写程序,编出一个适用小学加法计算题的小练习程序。
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Py40 PyQt5 tutorial
This program centers a window
on the screen.
author: Jan Bodnar
website: py40.com
last edited: January 2015
"""
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QDesktopWidget, QApplication, QPushButton, QVBoxLayout, QLineEdit, QHBoxLayout,
QLabel
import random
from pyqt5_plugins.examplebuttonplugin import QtGui
class Example(QWidget):
def __init__(self):
super().__init__()
self.score = 0
self.num1 = random.randint(1,20)
self.num2 = random.randint(1,20)
self.initUI()
def initUI(self):
self.resize(500, 200)
self.center()
self.btn()
self.setWindowTitle('两位数加法运算')
self.show()
# 控制窗口显示在屏幕中心的方法
def center(self):
# 获得窗口
qr = self.


