Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions Calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@
root = Tk()
root.title("Bruno's Calculator")

# default resolution of window
root.geometry("390x380")

# fixing the resolution. User will not be able to change resolution
root.maxsize(390,380)
root.minsize(390,380)

# changing background color. Making it more cool
root.config(bg="grey")

operation_number = 0
current_number_sum = 0
current_number_minus = 0
current_number_division = 0
current_number_multiply = 0

e = Entry(root, width = 50, borderwidth=5)
e.grid(row=0, column=0, columnspan=4)
e.grid(row=0, column=0, columnspan=4,pady=10)

def button_click(number, entry):
current_number = e.get()
Expand Down Expand Up @@ -210,32 +220,32 @@ def clear_entry():
current_number_division = 0
e.delete(0, END)

button_powerto = Button(root, borderwidth=2, text="xY",padx=36, pady=20, command= lambda: toPowerof()).grid(row=5, column=2)
button_point = Button(root, borderwidth=2, text=".", padx=41, pady=20, command= lambda: add_point()).grid(row=5, column=1)
button_powerto = Button(root, borderwidth=2, text="xY",padx=36, pady=20, command= lambda: toPowerof()).grid(row=5, column=2,padx=2)
button_point = Button(root, borderwidth=2, text=" .", padx=40, pady=20, command= lambda: add_point()).grid(row=5, column=1,padx=2)

button_sum = Button(root, borderwidth=2, text="+", padx=37, pady=20, command= lambda: sum_click()).grid(row=3, column=3)
button_equals = Button(root, borderwidth=2, text="=", padx=36, pady=20, command= lambda: equals_click()).grid(row=5, column=3)
button_clear = Button(root, borderwidth=2, text="CE", padx=37, pady=20,command= lambda: clear_entry()).grid(row=4, column=0)
button_sum = Button(root, borderwidth=2, text="+", padx=36, pady=20, command= lambda: sum_click()).grid(row=3, column=3,padx=2)
button_equals = Button(root,bg='#9ACD32', borderwidth=2, text="=", padx=36, pady=20, command= lambda: equals_click()).grid(row=5, column=3,padx=2)
button_clear = Button(root,bg="#B22222", fg="white",borderwidth=2, text="CE", padx=36, pady=20,command= lambda: clear_entry()).grid(row=4, column=0,padx=2)

button_minus = Button(root, borderwidth=2, text="-", padx=38, pady=20, command= lambda: minus_click()).grid(row=2, column=3)
button_multiply = Button(root, borderwidth=2, text="X", padx=37, pady=20, command= lambda: multiply_click()).grid(row=1, column=3)
button_negative_positive = Button(root, borderwidth=2, text="+/-", padx=37, pady=20, command= lambda: positive_negative()).grid(row=4, column=2)
button_minus = Button(root, borderwidth=2, text="-", padx=38, pady=20, command= lambda: minus_click()).grid(row=2, column=3,padx=2)
button_multiply = Button(root, borderwidth=2, text="X", padx=37, pady=20, command= lambda: multiply_click()).grid(row=1, column=3,padx=2)
button_negative_positive = Button(root, borderwidth=2, text="+/-", padx=34, pady=20, command= lambda: positive_negative()).grid(row=4, column=2,padx=2)

button_divide = Button(root, borderwidth=2, text="/", padx=38, pady=20, command= lambda: division_click()).grid(row=4, column=3)
button_del = Button(root, borderwidth=2, text="DEL",fg='red', padx=34, pady=20, command= lambda: delete()).grid(row=5, column=0)
button_0 = Button(root, borderwidth=2, text="0", padx=40, pady=20, command=lambda: button_click(0, e)).grid(row=4, column=1)
button_divide = Button(root, borderwidth=2, text="/", padx=38, pady=20, command= lambda: division_click()).grid(row=4, column=3,padx=2)
button_del = Button(root, borderwidth=2, text="DEL",fg='red', padx=33, pady=20, command= lambda: delete()).grid(row=5, column=0,padx=2)
button_0 = Button(root,bg="#66CDAA", borderwidth=2, text="0", padx=40, pady=20, command=lambda: button_click(0, e)).grid(row=4, column=1,padx=2)

button_1 = Button(root, borderwidth=2, text="1", padx=40, pady=20, command=lambda: button_click(1, e)).grid(row=3, column=0)
button_2 = Button(root, borderwidth=2, text="2", padx=40, pady=20, command=lambda: button_click(2, e)).grid(row=3, column=1)
button_3 = Button(root, borderwidth=2, text="3", padx=40, pady=20, command=lambda: button_click(3, e)).grid(row=3, column=2)
button_1 = Button(root,bg="#66CDAA", borderwidth=2, text="1", padx=40, pady=20, command=lambda: button_click(1, e)).grid(row=3, column=0,padx=2)
button_2 = Button(root,bg="#66CDAA", borderwidth=2, text="2", padx=40, pady=20, command=lambda: button_click(2, e)).grid(row=3, column=1,padx=2)
button_3 = Button(root,bg="#66CDAA", borderwidth=2, text="3", padx=40, pady=20, command=lambda: button_click(3, e)).grid(row=3, column=2,padx=2)

button_4 = Button(root, borderwidth=2, text="4", padx=40, pady=20, command=lambda: button_click(4, e)).grid(row=2, column=0)
button_5 = Button(root, borderwidth=2, text="5", padx=40, pady=20, command=lambda: button_click(5, e)).grid(row=2, column=1)
button_6 = Button(root, borderwidth=2, text="6", padx=40, pady=20, command=lambda: button_click(6, e)).grid(row=2, column=2)
button_4 = Button(root,bg="#66CDAA", borderwidth=2, text="4", padx=40, pady=20, command=lambda: button_click(4, e)).grid(row=2, column=0,padx=2)
button_5 = Button(root,bg="#66CDAA", borderwidth=2, text="5", padx=40, pady=20, command=lambda: button_click(5, e)).grid(row=2, column=1,padx=2)
button_6 = Button(root,bg="#66CDAA", borderwidth=2, text="6", padx=40, pady=20, command=lambda: button_click(6, e)).grid(row=2, column=2,padx=2)

button_7 = Button(root, borderwidth=2, text="7", padx=40, pady=20, command=lambda: button_click(7, e)).grid(row=1, column=0)
button_8 = Button(root, borderwidth=2, text="8", padx=40, pady=20, command=lambda: button_click(8, e)).grid(row=1, column=1)
button_9 = Button(root, borderwidth=2, text="9", padx=40, pady=20, command=lambda: button_click(9, e)).grid(row=1,column=2)
button_7 = Button(root,bg="#66CDAA", borderwidth=2, text="7", padx=40, pady=20, command=lambda: button_click(7, e)).grid(row=1, column=0,padx=2)
button_8 = Button(root,bg="#66CDAA", borderwidth=2, text="8", padx=40, pady=20, command=lambda: button_click(8, e)).grid(row=1, column=1,padx=2)
button_9 = Button(root,bg="#66CDAA", borderwidth=2, text="9", padx=40, pady=20, command=lambda: button_click(9, e)).grid(row=1,column=2,padx=2)



Expand Down
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# Python-Calculator
Calculator i made in python with tkinter
A very basic Calculator implemented in Python Programming Language using Tkinter Module.

Operations Available = 1. Addition 2. Substraction 3. Division 4. Multiplication and many more.

Advantages = 1. Bigger Buttons 2. Compact and Fast

------------------------------------BASICS------------------------------------------------
Python = is a Dynamically Typed, Object Oriented Programming Language
Tkinter = Inbuilt Python module --> to create simple GUI apps.
= Standard Python interface to Tk GUI toolkit.

Tk = is the toolkit

mainloop() = Most important function while working with Tkinter.
= You must call mainloop only one time. = It is an infinite loop.

-----------------------------BASIC Code for Tkinter---------------------------------- from tkinter import *

root = Tk() # 'root' is object of 'Tk' class
# creates a basic gui
# basic default compoments present in GUI
# A base is created -> for GUI Development
# we can create button, menu bar,etc on this base

root.mainloop() # event loop -> called only once