From 6f38268af77cf2995e682177c238aa50dc44f9d7 Mon Sep 17 00:00:00 2001 From: sharklab7 <55528399+sharklab7@users.noreply.github.com> Date: Thu, 1 Oct 2020 10:35:06 +0530 Subject: [PATCH 1/2] Update README.md Additional Information in Documentation for Developers. Makes the project more informative and easy to understand. --- README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3bde84b..1954592 100644 --- a/README.md +++ b/README.md @@ -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 From 2b7abeca629e2deadb822de2152ec3ed6e3b5f9a Mon Sep 17 00:00:00 2001 From: sharklab7 <55528399+sharklab7@users.noreply.github.com> Date: Thu, 1 Oct 2020 11:13:14 +0530 Subject: [PATCH 2/2] Update Calculator.py 1. Default Window size is now set. 2. Window size is fixed. Users will not be able to change resolution. 3, Overall alignment is fixed. 4. Colors are used more making it more attractive and easy to find the buttons. 5. Paddings are added various places to make it look more good and compact. --- Calculator.py | 52 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/Calculator.py b/Calculator.py index 0532924..6bbe417 100644 --- a/Calculator.py +++ b/Calculator.py @@ -4,6 +4,16 @@ 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 @@ -11,7 +21,7 @@ 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() @@ -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)