PYTHON Micro Project
PYTHON Micro Project
PYTHON Micro Project
Yash Pawar
4/22/2023
GUI Calculator Using PYTHON.
A Project Report On
“GUI CALCULATOR”
Submitted by:
Guided By :
Mr. P. H. Gutte
Submitted to
DEPARTMENT OF COMPUTER ENGINEERING,
1
GOVERNMENT POLYTECHNIC HINGOLI
Certificate
This is to certify that the project report entitled “GUI Calculator ” was
successfully completed by student of sixth semester diploma in Computer
Engineering.
NAME OF STUDENTS
2
ACKNOWLEDGEMENT
"I would like to express my sincere gratitude to all those who have contributed
to the completion of this report. First and foremost, I would like to thank Prof.
Mr. P H Gutte, my supervisor, for providing guidance and support throughout this
report. Without their valuable insights, this report would not have been possible.
Suraj Khandare, and Gopal Padalkar for their invaluable assistance in gathering
data and conducting research. Their contributions were essential in shaping the
(Principal of College) for providing me with the necessary resources and tools to
family and friends, who have provided me with encouragement and motivation
Thank you all for your contributions, support, and encouragement. Your efforts
3
Index
1 Introduction
7 Conclusion
4
1. Executive Summary
2. Course Outcomes :
5
3. Literature
Choose a GUI toolkit: Python has several popular GUI toolkits, such as
Tkinter, PyQt, and wxPython. Choose the one that best fits your needs and
familiarity with the toolkit.
Design the user interface: Decide on the layout of the calculator, including
the buttons, labels, and entry fields. Consider the user experience and
usability of the interface.
Create the GUI elements: Use the chosen GUI toolkit to create the
necessary elements of the user interface, such as buttons, labels, and entry
fields.
Define the calculator functions: Define the functions that perform the
calculations. For example, you could define a function to add two numbers
together or to calculate the square root of a number.
Implement the calculator logic: Use the functions you defined to implement
the calculator logic. For example, when the user clicks the "+" button, the
program should call the add function with the appropriate inputs.
Integrate the GUI and logic: Connect the GUI elements to the calculator
logic. For example, when the user clicks a button, the program should call
the appropriate function and update the display with the result.
6
Test and refine: Test the calculator thoroughly, and refine the user interface
and logic as necessary to improve its usability and functionality.
The result of a calculation: When the user performs a calculation, such as addition
or multiplication, the calculator should display the result on the screen.
Error messages: If the user inputs invalid data, such as non-numeric characters, the
calculator should display an error message indicating that the input is invalid.
Memory functions: Some calculators may have memory functions, such as storing a
value in memory or recalling a value from memory.
8
Business: A GUI calculator can be used in business settings to perform
financial calculations such as interest rates, currency conversions, or
profit margins.
User interface design: The user interface design can always be improved
to make the calculator more user-friendly and visually appealing.
Consider incorporating modern design principles and making the
calculator responsive to different screen sizes.
Integration with other tools: The calculator can be integrated with other tools and
software, such as spreadsheet programs or databases, to provide a more
comprehensive set of features and capabilities.
Introduction
10
from tkinter import *
window.resizable(False, False)
Next, we add the label widget to the GUI window using the pack()
method, which arranges the widget in the window based on the size
and location of other widgets.
The button click function is a critical part of a GUI calculator. It is responsible for
performing the appropriate calculation when a user clicks on a button. In a
simple calculator, the button click function would be responsible for adding,
subtracting, multiplying, or dividing two numbers based on the user input.
12
In the code example provided, we define a function called button_click() that
takes an event object as an input parameter. This function is bound to each
number and operator button using the bind() method. When a user clicks a
button, the function is called with the associated event object as an input
parameter.
The button_click() function first gets the text value of the button that was clicked
using the event.widget["text"] syntax. It then updates the display field with the
button's text value using the update_display() function.
Next, the function checks if the button clicked was an operator (+, -, *, /) or the
equal button. If the button was an operator, the function sets the operator
variable to the value of the clicked button. If the button clicked was the equal
button, the function performs the appropriate calculation based on the current
operator and the input values stored in the first_number and second_number
variables.
Math operation functions are essential for any GUI calculator. They are
responsible for performing arithmetic operations on the input values and
returning the result. In a simple calculator, the math operation functions would
be responsible for adding, subtracting, multiplying, or dividing two numbers.
In the code example provided, we define four math operation functions: add(),
subtract(), multiply(), and divide(). Each function takes two input parameters (x
and y) and returns the result of the appropriate arithmetic operation based on
the function name.
The add() function returns the sum of x and y, the subtract() function returns the
difference between x and y, the multiply() function returns the product of x and
y, and the divide() function returns the quotient of x and y.
The buttons are the primary way for users to input values and operators into the
calculator.
In the code example provided, we use the tkinter.Button() class to create each
button. We define a list of button labels (button_labels) and iterate over them to
create a button for each label. We also specify the button's size, font, and color
using the font and bg arguments.
To place the buttons on the calculator window, we use the grid() method to
specify the row and column positions of each button. We set the padx and pady
arguments to create padding between the buttons and the window edges.
We also bind the button_click() function to each button using the bind() method.
This ensures that the appropriate function is called when the user clicks a button.
Conclusion :
Group No: -
CO :
CO :
CO :
CO :
Marks:-
Marks obtained by
the
Marks for Total
Name and designation of Faculty Member: individual
Roll No. Group Work Marks
Name Of Student based on viva
(06) (10)
(04)
3131 Yash Sanjay Pawar
15