From 565aa3dcd6cb6779291cbbc4eb174b61d016d06b Mon Sep 17 00:00:00 2001 From: gavin <2861484755@qq.com> Date: Sat, 1 Apr 2017 12:02:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Bug#1=20=E8=BF=9E=E7=BB=AD?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=97=B6=EF=BC=8C=E8=8B=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=AC=A6=E6=94=B9=E5=8F=98=EF=BC=8C=E8=AE=A1=E7=AE=97=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- calc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/calc.py b/calc.py index ffff18c..e7c6b9e 100644 --- a/calc.py +++ b/calc.py @@ -69,7 +69,8 @@ class Calc(QMainWindow): if self.y is not None: #有y self.y =self.y + value else:#无y - self.y = value + if value != '0': + self.y = value self.text_result.setText(self.y) else:#无运算符 @@ -77,21 +78,25 @@ class Calc(QMainWindow): self.x = self.x + value else: - self.x = value + if value != '0': + self.x = value self.text_result.setText(self.x) # 开始处理运算符 # 1.点运算符时记录运算符 + # 2.点运算符时计算结果,然后记录运算符(x,y,oper都有值) # 2.点运算符时记录运算符并计算结果(x,y,oper都有值) # 3.点运算符时记录运算符,并将x置为0(x无值) + elif value in "+-*/": - self.operator = value + if self.x is None: self.x = 0 if self.x and self.y and self.operator: self.calculate() + self.operator = value # 处理点击等号的操作 # 1.点等号时计算结果 (x,y,oper都有值) -- Gitee