liuyuqi-dellpc 5 years ago
commit
363daa5b8f

+ 130 - 0
.gitignore

@@ -0,0 +1,130 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+#   However, in case of collaboration, if having platform-specific dependencies or dependencies
+#   having no cross-platform support, pipenv may install dependencies that don't work, or not
+#   install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+/.vscode

+ 141 - 0
Calculator.py

@@ -0,0 +1,141 @@
+import sys
+from PyQt5.uic import *
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+
+class Calculator(QMainWindow):
+    def __init__(self,title='Calculator',parent=None,uiFile=None):
+        super(Calculator,self).__init__(parent)
+        self.window=QMainWindow()
+        self.window.setWindowTitle('Calculator App : Made by Rahul')
+        loadUi(uiFile,self.window)
+
+        self.buttons_num=list()
+        for i in range(10):
+            butt_name='button_'+str(i)
+            button=self.window.findChild(QPushButton,butt_name)
+            button.released.connect(self.on_buttons_num_released)
+            self.buttons_num.append(button)
+        
+        self.button_dot=self.window.findChild(QPushButton,'button_dot')
+        self.button_dot.released.connect(self.on_button_dot_released)
+
+        
+        self.button_ac=self.window.findChild(QPushButton,'button_ac')
+        self.button_ac.released.connect(self.on_button_ac_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_del')
+        self.button_ac.released.connect(self.on_button_del_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_ans')
+        self.button_ac.released.connect(self.on_button_ans_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_equal')
+        self.button_ac.released.connect(self.on_button_equal_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_div')
+        self.button_ac.released.connect(self.on_buttons_opr_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_mult')
+        self.button_ac.released.connect(self.on_buttons_opr_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_add')
+        self.button_ac.released.connect(self.on_buttons_opr_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_sub')
+        self.button_ac.released.connect(self.on_buttons_opr_released)
+
+        self.button_ac=self.window.findChild(QPushButton,'button_exp')
+        self.button_ac.released.connect(self.on_buttons_opr_released)
+
+        self.display=self.window.findChild(QLabel,'display')
+        self.ans_label=self.window.findChild(QLabel,'ans_label')
+
+        self.answer=0.0
+
+        self.active_operator=None
+
+        self.window.show()
+
+    @pyqtSlot()
+    def on_button_ac_released(self):
+        self.display.setText('0')
+
+    @pyqtSlot()
+    def on_buttons_num_released(self):
+        button=self.sender()
+        if self.display.text()=='0' or self.display.text()=='0.0':
+            self.display.setText(button.text())
+        else:
+            text=self.display.text()
+            self.display.setText(text+button.text())
+
+    @pyqtSlot()
+    def on_button_dot_released(self):
+        text=self.display.text()
+        if '.' not in text and text!='':
+            self.display.setText(text+'.')
+
+    @pyqtSlot()
+    def on_button_del_released(self):
+        text=self.display.text()
+        if text[0:-1]=='':
+            self.display.setText('0')
+        else:
+            self.display.setText(text[0:-1])
+
+    @pyqtSlot()
+    def on_buttons_opr_released(self):
+        button=self.sender()
+        operator=button.text()
+        value=float(self.display.text())
+
+        if self.active_operator==None:
+            self.answer=value
+        else:
+            self.answer=self.operate(value,self.active_operator)
+
+        self.active_operator=operator
+        self.ans_label.setText('=  '+str(self.answer)+ ' '+self.active_operator)
+        self.display.setText('0')
+
+
+    @pyqtSlot()
+    def on_button_ans_released(self):
+        self.display.setText(str(self.answer))
+
+    @pyqtSlot()
+    def on_button_equal_released(self):
+
+        value=float(self.display.text())
+
+        if self.active_operator==None:
+            self.answer=value
+        else:
+            self.answer=self.operate(value,self.active_operator)
+
+        self.active_operator=None
+        self.ans_label.setText('= '+str(self.answer))
+        self.display.setText(str(self.answer))
+
+    def operate(self,value,operator):
+        if operator=='+':
+            self.answer+=value
+        elif operator=='-':
+            self.answer-=value
+        elif operator=='*':
+            self.answer*=value
+        elif operator=='/':
+            self.answer/=value
+        elif operator=='^':
+            self.answer=self.answer**value
+        return self.answer
+        
+            
+
+
+if __name__=='__main__':
+    testApp=QApplication(sys.argv)
+    calc=Calculator(title='Calculator',parent=None,uiFile='form/ui_calculator.ui')
+    testApp.exec_()

+ 10 - 0
README.md

@@ -0,0 +1,10 @@
+# Calculator
+python project. Calculator made using PyQt5 
+************************
+
+![](shotscreen/BaiduHi_2019-12-17_6-21-55.png)
+
+Made By : 
+liuyuqi.gov@msn.cn
+
+![](http://blog.yoqi.me/wp-content/themes/Jianux/images/donate.gif)

+ 1008 - 0
form/ui_calculator.ui

@@ -0,0 +1,1008 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>500</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>400</width>
+    <height>500</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>400</width>
+    <height>500</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Calculator : by Rahul</string>
+  </property>
+  <property name="windowIcon">
+   <iconset resource="../resources/Calculator.qrc">
+    <normaloff>:/images/images/Calculator.png</normaloff>:/images/images/Calculator.png</iconset>
+  </property>
+  <property name="styleSheet">
+   <string notr="true"/>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <property name="sizePolicy">
+    <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+     <horstretch>0</horstretch>
+     <verstretch>0</verstretch>
+    </sizepolicy>
+   </property>
+   <property name="styleSheet">
+    <string notr="true">background-color : #336699;</string>
+   </property>
+   <layout class="QVBoxLayout" name="verticalLayout">
+    <item>
+     <layout class="QGridLayout" name="grid" rowstretch="1,4,2,2,2,2,2">
+      <property name="sizeConstraint">
+       <enum>QLayout::SetDefaultConstraint</enum>
+      </property>
+      <property name="spacing">
+       <number>0</number>
+      </property>
+      <item row="5" column="1">
+       <widget class="QPushButton" name="button_2">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>2</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="2">
+       <widget class="QPushButton" name="button_9">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>9</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="2">
+       <widget class="QPushButton" name="button_3">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>3</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="1">
+       <widget class="QPushButton" name="button_5">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>5</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="0">
+       <widget class="QPushButton" name="button_1">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>1</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0">
+       <widget class="QPushButton" name="button_7">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>7</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="3">
+       <widget class="QPushButton" name="button_mult">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #e65c00;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>*</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="2">
+       <widget class="QPushButton" name="button_ans">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="toolTip">
+         <string>Answer</string>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #009933;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>Ans</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="3">
+       <widget class="QPushButton" name="button_add">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #e65c00;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>+</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0">
+       <widget class="QPushButton" name="button_4">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>4</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0">
+       <widget class="QPushButton" name="button_ac">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="toolTip">
+         <string>All Clear</string>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #bd0f0f;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>AC</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="2">
+       <widget class="QPushButton" name="button_equal">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #009933;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>=</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="3">
+       <widget class="QPushButton" name="button_div">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #e65c00;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>/</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="1">
+       <widget class="QPushButton" name="button_0">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>0</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1">
+       <widget class="QPushButton" name="button_8">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>8</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="0">
+       <widget class="QPushButton" name="button_dot">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>.</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" colspan="4">
+       <widget class="QLabel" name="ans_label">
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>15</pointsize>
+          <weight>50</weight>
+          <bold>false</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">background-color : white;
+border : none;
+padding: 7px;
+color : grey;</string>
+        </property>
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="3">
+       <widget class="QPushButton" name="button_sub">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #e65c00;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>-</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="1">
+       <widget class="QPushButton" name="button_del">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="toolTip">
+         <string>Backspace</string>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #bd0f0f;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>Del</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="6" column="3">
+       <widget class="QPushButton" name="button_exp">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : #e65c00;
+	border : none;
+	border-radius : 7px;
+	color : white;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>^</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="2">
+       <widget class="QPushButton" name="button_6">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>18</pointsize>
+          <weight>75</weight>
+          <bold>true</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">QPushButton
+{
+	background-color : #336699;
+	border : none;
+	color : white;
+	margin: 5px;
+}
+
+QPushButton:hover
+{
+	background-color : white;
+	border : none;
+	border-radius : 7px;
+	color : black;
+	margin: 5px;
+}
+
+</string>
+        </property>
+        <property name="text">
+         <string>6</string>
+        </property>
+        <property name="flat">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" colspan="4">
+       <widget class="QLabel" name="display">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="font">
+         <font>
+          <family>Arial</family>
+          <pointsize>30</pointsize>
+          <weight>50</weight>
+          <bold>false</bold>
+         </font>
+        </property>
+        <property name="styleSheet">
+         <string notr="true">background-color: white;
+color : black;
+padding : 10px;</string>
+        </property>
+        <property name="text">
+         <string>0</string>
+        </property>
+        <property name="alignment">
+         <set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources>
+  <include location="../resources/Calculator.qrc"/>
+ </resources>
+ <connections/>
+</ui>

+ 12 - 0
main.py

@@ -0,0 +1,12 @@
+import sys
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
+from PyQt5.QtWidgets import *
+from PyQt5.uic import *
+from Calculator import Calculator
+
+if __name__ == "__main__":
+    app = QApplication(sys.argv)
+    calculator = Calculator(title='Calculator', parent=None,
+                            uiFile='form/ui_calculator.ui')
+    app.exec_()

+ 7 - 0
pyinstaller.py

@@ -0,0 +1,7 @@
+import  os,sys,shutil
+import PyInstaller
+if __name__ == '__main__':
+    os.system("pyinstaller main.py -F -w --icon=resources/images/favicon.ico")
+    os.mkdir("dist/form")
+    shutil.copyfile("form/ui_calculator.ui","dist/form/ui_calculator.ui")
+    shutil.copytree("resources","dist/resources")

+ 3 - 0
requirements.txt

@@ -0,0 +1,3 @@
+PyInstaller==3.5
+PyQt5==5.13.2
+pyqt5-tools==5.13.0.1.5

+ 5 - 0
resources/Calculator.qrc

@@ -0,0 +1,5 @@
+<RCC>
+  <qresource prefix="images">
+    <file>images/Calculator.png</file>
+  </qresource>
+</RCC>

BIN
resources/images/Calculator.png


BIN
resources/images/favicon.ico


BIN
shotscreen/BaiduHi_2019-12-17_6-21-55.png