From 13604e9b942c61787c03ffdaf84ed68d42ac9f97 Mon Sep 17 00:00:00 2001 From: Yashwant Singh <72186370+Yashwant-Singh-99312@users.noreply.github.com> Date: Thu, 1 Oct 2020 13:56:16 +0530 Subject: [PATCH 1/3] A simple GUI calculator using python coding. --- Readme.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/Readme.txt b/Readme.txt index 4c64943..ca70b26 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1 +1,89 @@ -A simple GUI calculator written in python using Tkinter library. +# A simple GUI calculator written in python using Tkinter library. +# This is the program to make a simple GUI calculator in python. +# You can copy the command from below and paste it in your IDE. + + +import sys +from PyQt4.QtGui import * +#from PyQt4 import QtGui + +app = QApplication(sys.argv) +widget = QWidget() +label = QLabel("", widget) + +btnAdd = QPushButton("Add", widget) +btnSub = QPushButton("Subtract", widget) +btnDiv = QPushButton("Divide", widget) +btnMul = QPushButton("Multiply", widget) + + +#txtArea = QPlainTextEdit("Text To Edit", widget)widget.resize + +txtArea1 = QLineEdit("", widget) +txtArea2 = QLineEdit("", widget) + +def init(): + + widget.resize(300, 300) + widget.move(300, 300) + widget.setWindowTitle('Calculator') + widget.show() + + txtArea1.move(20,10) + txtArea1.show() + txtArea2.move(20,60) + txtArea2.show() + + label.setText("") + label.move(20,110) + label.show() + + btnAdd.setToolTip('Addition') + btnAdd.move(20,160) + btnAdd.clicked.connect(addition) + btnAdd.show() + + btnSub.setToolTip('Subtraction') + btnSub.move(110,160) + btnSub.clicked.connect(subtraction) + btnSub.show() + + btnDiv.setToolTip('Division') + btnDiv.move(20,210) + btnDiv.clicked.connect(division) + btnDiv.show() + + btnMul.setToolTip('Multiplication') + btnMul.move(110,210) + btnMul.clicked.connect(multiplication) + btnMul.show() + + +def addition(): + num1 = int(txtArea1.text()) + num2 = int(txtArea2.text()) + label.setFixedWidth(200) + label.setText("Addition: "+str(num1 + num2)) + +def subtraction(): + num1 = int(txtArea1.text()) + num2 = int(txtArea2.text()) + label.setFixedWidth(200) + label.setText("Subtraction: "+str(num1 - num2)) + +def multiplication(): + num1 = int(txtArea1.text()) + num2 = int(txtArea2.text()) + label.setFixedWidth(200) + label.setText("Multiplication: "+str(num1 * num2)) + +def division(): + num1 = int(txtArea1.text()) + num2 = int(txtArea2.text()) + label.setFixedWidth(200) + label.setText("Division: "+str(num1 / num2)) + +if __name__ == "__main__": + init() + +app.exec_() From c7afecf93bdb62009da63153e4a32ad5b201b792 Mon Sep 17 00:00:00 2001 From: Yashwant Singh <72186370+Yashwant-Singh-99312@users.noreply.github.com> Date: Fri, 1 Oct 2021 01:00:25 +0530 Subject: [PATCH 2/3] Update Readme.txt --- Readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.txt b/Readme.txt index ca70b26..1e76a31 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,6 +1,6 @@ # A simple GUI calculator written in python using Tkinter library. # This is the program to make a simple GUI calculator in python. -# You can copy the command from below and paste it in your IDE. + import sys From f46f98f96ad39832143543a9faaf27b399ea0fe5 Mon Sep 17 00:00:00 2001 From: Yashwant Singh <72186370+Yashwant-Singh-99312@users.noreply.github.com> Date: Fri, 1 Oct 2021 01:02:06 +0530 Subject: [PATCH 3/3] Update Readme.txt --- Readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.txt b/Readme.txt index 1e76a31..b9d3531 100644 --- a/Readme.txt +++ b/Readme.txt @@ -1,6 +1,6 @@ # A simple GUI calculator written in python using Tkinter library. # This is the program to make a simple GUI calculator in python. - +# The code can be copied to your preferred IDE. import sys