下面我们将介绍使用python的PyQt5图形界面来编写一个简易的计算器,实现“加,减,乘,除,平方,开方”等运算。
代码如下:
from PyQt5.QtGui import *
from PyQt5.Qt import *
from PyQt5.QtCore import *
import sys,math,string
class Calculator(QWidget):
def __init__(self,parent=None):
QWidget.__init__(self,parent=parent)
self.initUI()
self.last=[]
def initUI(self):
list=['&','**','s','C',7,8,