Creating A Calculator Using Tkinter | Python Tkinter GUI Tutorial In Hindi #27

preview_player
Показать описание


Best Hindi Videos For Learning Programming:

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

God bless you! Om namah shivay jay mahakal bless uou

rajdave
Автор

Thanks a lot Harry. Your tutorials were really amazing. I just want to add something in this tutorial. Instead of changing padding of each button, we can increase the width of each button and set it to constant say, width =4. Then, we wont need to manually check padding. GUI will become well structured in no time.

bharatgoyal
Автор

Here is a calculator that has more features (trigno + log)
from tkinter import *
from tkinter import messagebox
import math
import numpy


def message():
Us', message='This calculator was made with code and love')


def type_input(val):
input.insert(END, val)


def clear():
input.delete(0, END)


def solve(expre):
try:
res = eval(expre)
result.insert(END, f'answer = {res}')
except:
try:
expre = expre.replace('sin', 'math.sin')
expre = expre.replace('cos', 'math.cos')
expre = expre.replace('tan', 'math.tan')
expre = expre.replace('log', 'math.log')
expre = expre.replace('exp', 'math.e**')
res = eval(expre)
result.insert(END, f'answer = {res}')
except:
Expression', message='Please provide valid expression')



window = Tk()
window.geometry('350x600')
window.title('GUI calculator')

menu_bar = Menu(window)

open = Menu(menu_bar, tearoff=0)
exit = Menu(menu_bar, tearoff=0)
me', menu=open)
open.add_command(label='About Us', command=message)
menu_bar.add_cascade(label='Exit', menu=exit)
exit.add_command(label='Close', command=quit)
window.config(menu=menu_bar)

#l1 = Label(window, text='Welcome to CALC').grid(row=0, column=0)
#Label(window, text='Output -->').grid(rowspan=1, columnspan=1)
top_frame = Frame(window).pack()
Label(top_frame, text='Output', font=('Comic Sans MS', 20)).pack()
result = Listbox(top_frame, height=5, width=20, font=('lucida', 20, 'bold'))
result.pack(pady=10)

#Label(window, text='Input -->').grid(row=1, column =0)
input = Entry(top_frame, width=50, borderwidth=5, bd=5, font=('lucida', 15, 'bold'))
input.pack(pady=10)
input.focus_set()


keys = Frame(window)
keys.pack()

# number buttons

b0 = Button(keys, text='0', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(0), font=('lucida', 10, 'bold')).grid(row=2, column=0)
b1 = Button(keys, text='1', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(1), font=('lucida', 10, 'bold')).grid(row=2, column=1)
b2 = Button(keys, text='2', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(2), font=('lucida', 10, 'bold')).grid(row=2, column=2)
b3 = Button(keys, text='3', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(3), font=('lucida', 10, 'bold')).grid(row=3, column=0)
b4 = Button(keys, text='4', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(4), font=('lucida', 10, 'bold')).grid(row=3, column=1)
b5 = Button(keys, text='5', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(5), font=('lucida', 10, 'bold')).grid(row=3, column=2)
b6 = Button(keys, text='6', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(6), font=('lucida', 10, 'bold')).grid(row=4, column=0)
b7 = Button(keys, text='7', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(7), font=('lucida', 10, 'bold')).grid(row=4, column=1)
b8 = Button(keys, text='8', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(8), font=('lucida', 10, 'bold')).grid(row=4, column=2)
b9 = Button(keys, text='9', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input(9), font=('lucida', 10, 'bold')).grid(row=5, column=0)
b10 = Button(keys, text='+', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input('+'), font=('lucida', 10, 'bold')).grid(row=5, column=1)
b11 = Button(keys, text='-', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input('-'), font=('lucida', 10, 'bold')).grid(row=5, column=2)
b12 = Button(keys, text='X', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input('*'), font=('lucida', 10, 'bold')).grid(row=6, column=0)
b13 = Button(keys, text='/', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input('/'), font=('lucida', 10, 'bold')).grid(row=6, column=1)
b14 = Button(keys, text='==', padx=35, relief=GROOVE, borderwidth=5, command=lambda: solve(input.get()), font=('lucida', 10, 'bold')).grid(row=6, column=2)
b15 = Button(keys, text='sin', padx=35, relief=GROOVE, borderwidth=5, command=lambda: type_input('sin'), font=('lucida', 10, 'bold')).grid(row=7, column=0)
b16 = Button(keys, text='cos', padx=33, relief=GROOVE, borderwidth=5, command=lambda: type_input('cos'), font=('lucida', 10, 'bold')).grid(row=7, column=1)
b17 = Button(keys, text='tan', padx=35, relief=GROOVE, borderwidth=5, command=lambda: type_input('tan'), font=('lucida', 10, 'bold')).grid(row=7, column=2)
b18 = Button(keys, text='log', padx=35, relief=GROOVE, borderwidth=5, command=lambda: type_input('log'), font=('lucida', 10, 'bold')).grid(row=8, column=0)
b19 = Button(keys, text='.', padx=40, relief=GROOVE, borderwidth=5, command=lambda: type_input('.'), font=('lucida', 10, 'bold')).grid(row=8, column=1)
b20 = Button(keys, text='exp', padx=35, relief=GROOVE, borderwidth=5, command=lambda: type_input('exp'), font=('lucida', 10, 'bold')).grid(row=8, column=2)
b21 = Button(keys, text='(', padx=42, relief=GROOVE, borderwidth=5, command=lambda: type_input('('), font=('lucida', 10, 'bold')).grid(row=9, column=0)
b22 = Button(keys, text=')', padx=42, relief=GROOVE, borderwidth=5, command=lambda: type_input(')'), font=('lucida', 10, 'bold')).grid(row=9, column=1)
b23 = Button(keys, text='clear', padx=32, relief=GROOVE, borderwidth=5, command=clear, font=('lucida', 10, 'bold')).grid(row=9, column=2)


status = StringVar()
status.set('CALCULATOR made with code')

Label(window, textvariable=status, width=30, relief=SUNKEN, bg='pink', fg='black', font=('Comic Sans MS', 15)).pack(side=BOTTOM, fill=X)

window.mainloop()

adityamaurya
Автор

Kyaa 2 saal baad dill milega Harry bhai🤡

amish
Автор

Hey Harry! Here's my best attempt of reducing the amount of code. I managed to reduce it by half [65 lines]...(I tried my best to reduce the lines while maintaining design and uniformity, so there might be repetitions, and it might not be the best way.) Here's the code:

from tkinter import *
root = Tk()
root.geometry("620x888")
root.title("Calculator")

def click(event):
global svalue
text = event.widget.cget("text")

if text == "=":
if svalue.get().isdigit():
value = int(svalue.get())
else:
try:
value = eval(svalue.get())
except Exception as e:
print(e)
value= "Error"

svalue.set(value)
screen.update()

elif text == "C":
svalue.set("")
screen.update()
else:
svalue.set(svalue.get() + text)
screen.update()


#TheScreenEntry:
svalue = StringVar()
screen = Entry(root, textvariable= svalue, font="lucida 40 italic")
screen.pack(fill=X, padx=10, pady=5, ipadx=8)

#WhileLoopForButtonsFrom1-9:
x = 1
while x<=7:
f = Frame(root, bg="grey")
b= Button(f, text=str(x), padx=12, pady=12, font="lucida 35 bold", relief=RAISED)
b.pack(padx=18, pady=18, side=LEFT)
b.bind("<Button-1>", click)

b = Button(f, text=str(x+1), padx=12, pady=12, font="lucida 35 bold", relief=RAISED)
b.pack(padx=18, pady=18, side=LEFT)
b.bind("<Button-1>", click)

b= Button(f, text=str(x+2), padx=12, pady=12, font="lucida 35 bold", relief=RAISED)
b.pack(padx=18, pady=18, side=LEFT)
b.bind("<Button-1>", click)

f.pack()
x+=3

#AnotherFrameForThe0Button, SoThatItComesAtTheBottom:
f = Frame(root, bg="grey")
b= Button(f, text="0", padx=12, pady=12, font="lucida 35 bold", relief=RAISED)
b.pack(padx=18, pady=18, side=LEFT)
b.bind("<Button-1>", click)
f.pack()

#The miscellanious buttons {have their own frame}:
f = Frame(root, bg="grey")

#ForLoop-forTheMisc.Buttons
list1 = ["C", "/", "%", "*", "=", "+", "-"]
for item in list1:
b= Button(f, text=str(item), padx=12, pady=12, font="lucida 35 bold", relief=RAISED)
b.pack(padx=18, pady=18, side=LEFT)
b.bind("<Button-1>", click)
f.pack()

root.mainloop()

saptakmukherjee
Автор

# Harry bro, for loop laga kr try kiya hai aur thoda designing dark theme ki tarah kr diya hai. Have a look :)
from tkinter import *


# logic of calculator goes
def click(event):
global scvalue

# Will automatically clear the display if Error is generated in previous calculations
if display.get() == "Error":
scvalue.set("")
display.update()

# Will extract the value of the clicked button
text = event.widget.cget("text")

# if "=" button is clicked, it will evaluate the expression on the display
if text == "=":
if scvalue.get().isdigit():
value = int(scvalue.get())
else:
# when the evaluating expression is not valid
try:
value = eval(display.get())
except Exception as e:
value = "Error"
print(e)

# updating the display with the result
scvalue.set(value)
display.update()

# if "C" button is clicked, it will clear the display
elif text == "C":
scvalue.set("")
display.update()

# if "<-" button is clicked, it will erase the last char of expression on the display
elif text == "<-":

display.update()

# except all above, if any other button is clicked, it will be appended to the expression on the display
else:
scvalue.set(scvalue.get() + text)
display.update()


# the GUI
root = Tk()
root.geometry("345x640")
root.minsize(345, 640)
root.maxsize(345, 640)
root.title("Calculator by Atharva")


scvalue = StringVar()
scvalue.set("")

# Creating main display where i/o will be displayed
display = Entry(root, textvariable=scvalue, font=("times new roman", 35, "bold"),
justify=RIGHT, bg="black", fg="white", relief=FLAT)
display.pack(side=TOP, fill=X, pady=10, padx=10, ipady=20)

# List of buttons to be placed in the calculator
buttons = [["C", "%", "<-", "/"],
["7", "8", "9", "*"],
["4", "5", "6", "-"],
["1", "2", "3", "+"],
["00", "0", ".", "="]]

# creating buttons using for loops and iterating the items in above list
for row in buttons:
f = Frame(root, bg="black", borderwidth=0)
f.pack(side=TOP, fill=X, padx=20)
for btn in row:
b = Button(f, text=btn, font=("times new roman", 28, "bold"), relief=FLAT,
width=3, height=1, pady=15, bg="black", fg="white",
activebackground="black", activeforeground="white")
b.pack(side=LEFT)
b.bind("<Button-1>", click)

root.mainloop()

alvarule
Автор

short key key is ctrl + mouse scroll, but first you need to enable this in setting in pycharm ->

first open pycharm -> press crl+alt+s(settings) -> editor settings -> general > tick the first option(you will see a option saying "change font size with mouse scull wheel")

parthgupta
Автор

Thank You Harry. For this awesome series i learn lot of new things from you videos.

bhumikapatel
Автор

from tkinter import *
# creating basic window

window = Tk()

window.geometry("312x324") # size of the window width:- 500, height:- 375

window.resizable(0, 0) # this prevents from resizing the window

window.title("Calcualtor")

functions

# 'btn_click' function continuously updates the input field whenever you enters a number

def btn_click(item):

global expression

expression = expression + str(item)

input_text.set(expression)

# 'btn_clear' function clears the input field

def btn_clear():

global expression

expression = ""

input_text.set("")

# 'btn_equal' calculates the expression present in input field

def btn_equal():

global expression

result = str(eval(expression)) # 'eval' function evalutes the string expression directly

# you can also implement your own function to evalute the expression istead of 'eval' function

input_text.set(result)

expression = ""

expression = ""

# 'StringVar()' is used to get the instance of input field

input_text = StringVar()

# creating a frame for the input field



input_frame = Frame(window, width = 312, height = 50, bd = 0, highlightbackground = "black", highlightcolor = "black", highlightthickness = 1)



input_frame.pack(side = TOP)



# creating a input field inside the 'Frame'



input_field = Entry(input_frame, font = ('arial', 18, 'bold'), textvariable = input_text, width = 50, bg = "#eee", bd = 0, justify = RIGHT)



input_field.grid(row = 0, column = 0)



input_field.pack(ipady = 10) # 'ipady' is internal padding to increase the height of input field



# creating another 'Frame' for the button below the 'input_frame'



btns_frame = Frame(window, width = 312, height = 272.5, bg = "grey")

btns_frame.pack()

# first row

clear = Button(btns_frame, text = "C", fg = "black", width = 32, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_clear()).grid(row = 0, column = 0, columnspan = 3, padx = 1, pady = 1)

divide = Button(btns_frame, text = "/", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("/")).grid(row = 0, column = 3, padx = 1, pady = 1)

# second row

seven = Button(btns_frame, text = "7", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(7)).grid(row = 1, column = 0, padx = 1, pady = 1)

eight = Button(btns_frame, text = "8", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(8)).grid(row = 1, column = 1, padx = 1, pady = 1)

nine = Button(btns_frame, text = "9", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(9)).grid(row = 1, column = 2, padx = 1, pady = 1)

multiply = Button(btns_frame, text = "*", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("*")).grid(row = 1, column = 3, padx = 1, pady = 1)

# third row

four = Button(btns_frame, text = "4", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(4)).grid(row = 2, column = 0, padx = 1, pady = 1)

five = Button(btns_frame, text = "5", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(5)).grid(row = 2, column = 1, padx = 1, pady = 1)

six = Button(btns_frame, text = "6", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(6)).grid(row = 2, column = 2, padx = 1, pady = 1)

minus = Button(btns_frame, text = "-", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("-")).grid(row = 2, column = 3, padx = 1, pady = 1)

# fourth row

one = Button(btns_frame, text = "1", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(1)).grid(row = 3, column = 0, padx = 1, pady = 1)

two = Button(btns_frame, text = "2", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(2)).grid(row = 3, column = 1, padx = 1, pady = 1)

three = Button(btns_frame, text = "3", fg = "black", width = 10, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(3)).grid(row = 3, column = 2, padx = 1, pady = 1)

plus = Button(btns_frame, text = "+", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click("+")).grid(row = 3, column = 3, padx = 1, pady = 1)

# fourth row

zero = Button(btns_frame, text = "0", fg = "black", width = 21, height = 3, bd = 0, bg = "#fff", cursor = "hand2", command = lambda: btn_click(0)).grid(row = 4, column = 0, columnspan = 2, padx = 1, pady = 1)

point = Button(btns_frame, text = ".", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_click(".")).grid(row = 4, column = 2, padx = 1, pady = 1)

equals = Button(btns_frame, text = "=", fg = "black", width = 10, height = 3, bd = 0, bg = "#eee", cursor = "hand2", command = lambda: btn_equal()).grid(row = 4, column = 3, padx = 1, pady=1)

window.mainloop()

mnfftxo
Автор

Thank u sir for making tutorials for us. U are such a hardworker

abhisheksehgal
Автор

Thank you Harry Sir for this amazing tutorials. It's my humbly request to make videoes on implementation of Data Structure & Algorithm with the help of Python

nishantpatel
Автор

My OOP Calculator!!


from tkinter import *
import tkinter.messagebox as tmsg


class Calculator(Tk):
def __init__(self):
super().__init__()
self.geometry("450x450")

def typer(self):
self.scvalue = StringVar()
self.scvalue.set("")
self.screen = Entry(self, textvar=self.scvalue, font="chiller 35 bold italic")
self.screen.pack(fill=X, ipadx=5, ipady=7, padx=10, pady=10)

def btns(self):
rowk = [3, 3, 3, 2, 2, 2, 1, 1, 1]
colk = [3, 2, 1, 3, 2, 1, 3, 2, 1]
self.f = Frame(self, bg='grey')
for i in range(0, 9):
self.btn = Button(self.f, text=f"{i+1}", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btn.grid(row=rowk[i], column=colk[i], sticky=NSEW, padx=5, pady=5)
self.btn.bind('<Button-1>', self.click)

self.btn0 = Button(self.f, text="0", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btn0.grid(row=4, column=1, sticky=NSEW, padx=5, pady=5)
self.btn0.bind('<Button-1>', self.click)
self.btne = Button(self.f, text="=", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btne.grid(row=4, column=2, columnspan=2, sticky=NSEW, padx=5, pady=5)
self.btne.bind('<Button-1>', self.click)
self.btns1 = ['+', '-', '*', '/', '.', 'C', 'AC']
self.row2 = [1, 1, 2, 2, 3, 3]
self.col2 = [4, 5, 4, 5, 4, 5]
# for i in range(0, 6):
for i in range(len(self.btns1)-1):
self.btn1 = Button(self.f, text=f"{self.btns1[i]}", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btn1.grid(row=self.row2[i], column=self.col2[i], sticky=NSEW, padx=5, pady=5)
self.btn1.bind('<Button-1>', self.click)
self.btn2 = Button(self.f, text=f"{self.btns1[i]}", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btn2.grid(row=self.row2[i], column=self.col2[i], sticky=NSEW, padx=5, pady=5)
self.btn2.bind('<Button-1>', self.click)
self.btnac = Button(self.f, text="AC", font="chiller 25 bold italic", width=4, height=1, relief=SUNKEN, borderwidth=3)
self.btnac.grid(row=4, column=4, columnspan=2, sticky=NSEW, padx=5, pady=5)
self.btnac.bind('<Button-1>', self.click)
self.f.pack(anchor=CENTER)


def click(self, event):
global scvalue
self.text = event.widget.cget("text")

if self.text == '=':
if
self.operators = ['+', '-', '*', '/', '.']
self.temp1 = str(self.scvalue.get())
if
self.aa = tmsg.showinfo("Error", "Can't do this operation")
self.c = str(self.scvalue.get())
self.temp = len(self.c) - 1
self.c = self.c[0:self.temp]
self.scvalue.set(self.c)
self.screen.update()
else:
self.val = int(self.scvalue.get())
self.scvalue.set(self.val)
self.screen.update()
else:
self.operators = ['+', '-', '*', '/', '.']
self.temp1 = str(self.scvalue.get())
if
self.aa = tmsg.showinfo("Error", "Can't do this operation")
self.c = str(self.scvalue.get())
self.temp = len(self.c) - 1
self.c = self.c[0:self.temp]
self.scvalue.set(self.c)
self.screen.update()
else:
self.val = eval(self.scvalue.get())
# for whole numbers as ouput use this:
self.scvalue.set(self.val)
self.screen.update()

elif self.text == 'C' or self.text == 'AC':
if self.text == 'AC':
self.scvalue.set("")
self.screen.update()
else:
self.c = str(self.scvalue.get())
self.temp = len(self.c)-1
self.c = self.c[0:self.temp]
self.scvalue.set(self.c)
self.screen.update()

else:
+ self.text)
self.screen.update()


if __name__ == '__main__':
window = Calculator()
window.typer()
window.btns()
window.mainloop()

mihirgoplani
Автор

This is very useful vedio for me ???
I know how to made calculator in GUI programming.
thanku so much sir

sunn
Автор

# Python program to create a simple GUI
# calculator using Tkinter

# import everything from tkinter module
from tkinter import *

# globally declare the expression variable
expression = ""


# Function to update expressiom
# in the text entry box
def press(num):
# point out the global expression variable
global expression

# concatenation of string
expression = expression + str(num)

# update the expression by using set method
equation.set(expression)


# Function to evaluate the final expression
def equalpress():
# Try and except statement is used
# for handling the errors like zero
# division error etc.

# Put that code inside the try block
# which may generate the error
try:

global expression

# eval function evaluate the expression
# and str function convert the result
# into string
total = str(eval(expression))

equation.set(total)

# initialze the expression variable
# by empty string
expression = ""

# if error is generate then handle
# by the except block
except:

equation.set(" error ")
expression = ""


# Function to clear the contents
# of text entry box
def clear():
global expression
expression = ""
equation.set("")


# Driver code
if __name__ == "__main__":
# create a GUI window
gui = Tk()

# set the background colour of GUI window
green")

# set the title of GUI window
gui.title("Simple Calculator")

# set the configuration of GUI window
gui.geometry("270x150")

# StringVar() is the variable class
# we create an instance of this class
equation = StringVar()

# create the text entry box for
# showing the expression .
expression_field = Entry(gui, textvariable=equation)

# grid method is used for placing
# the widgets at respective positions
# in table like structure .
expression_field.grid(columnspan=4, ipadx=70)

equation.set('enter your expression')

# create a Buttons and place at a particular
# location inside the root window .
# when user press the button, the command or
# function affiliated to that button is executed .
button1 = Button(gui, text=' 1 ', fg='black', bg='red',
command=lambda: press(1), height=1, width=7)
button1.grid(row=2, column=0)

button2 = Button(gui, text=' 2 ', fg='black', bg='red',
command=lambda: press(2), height=1, width=7)
button2.grid(row=2, column=1)

button3 = Button(gui, text=' 3 ', fg='black', bg='red',
command=lambda: press(3), height=1, width=7)
button3.grid(row=2, column=2)

button4 = Button(gui, text=' 4 ', fg='black', bg='red',
command=lambda: press(4), height=1, width=7)
button4.grid(row=3, column=0)

button5 = Button(gui, text=' 5 ', fg='black', bg='red',
command=lambda: press(5), height=1, width=7)
button5.grid(row=3, column=1)

button6 = Button(gui, text=' 6 ', fg='black', bg='red',
command=lambda: press(6), height=1, width=7)
button6.grid(row=3, column=2)

button7 = Button(gui, text=' 7 ', fg='black', bg='red',
command=lambda: press(7), height=1, width=7)
button7.grid(row=4, column=0)

button8 = Button(gui, text=' 8 ', fg='black', bg='red',
command=lambda: press(8), height=1, width=7)
button8.grid(row=4, column=1)

button9 = Button(gui, text=' 9 ', fg='black', bg='red',
command=lambda: press(9), height=1, width=7)
button9.grid(row=4, column=2)

button0 = Button(gui, text=' 0 ', fg='black', bg='red',
command=lambda: press(0), height=1, width=7)
button0.grid(row=5, column=0)

plus = Button(gui, text=' + ', fg='black', bg='red',
command=lambda: press("+"), height=1, width=7)
plus.grid(row=2, column=3)

minus = Button(gui, text=' - ', fg='black', bg='red',
command=lambda: press("-"), height=1, width=7)
minus.grid(row=3, column=3)

multiply = Button(gui, text=' * ', fg='black', bg='red',
command=lambda: press("*"), height=1, width=7)
multiply.grid(row=4, column=3)

divide = Button(gui, text=' / ', fg='black', bg='red',
command=lambda: press("/"), height=1, width=7)
divide.grid(row=5, column=3)

equal = Button(gui, text=' = ', fg='black', bg='red',
command=equalpress, height=1, width=7)
equal.grid(row=5, column=2)

clear = Button(gui, text='Clear', fg='black', bg='red',
command=clear, height=1, width=7)
clear.grid(row=5, column='1')

Decimal= Button(gui, text='.', fg='black', bg='red',
command=lambda: press('.'), height=1, width=7)
Decimal.grid(row=6, column=0)
# start the GUI
gui.mainloop()

lalitgoswami
Автор

20:49

Connected to mongodb
Show history and
Sharing options
Ruf work paper like paint

yashrayjada
Автор

Harry bhai pls make a one video on tkinter pls harry bhai your newer version video will be much better then this one, also I can bet that video will spread more faster then corona harry bhai pls.

parthgupta
Автор

Thank you so much sir really i got perfect way to learn tkinter from your videos...
The way you explain things really it's a good and easy to understand...
Thank you again sir 🙏

vikashkumar
Автор

Assalam. O. Alaikum!
Harry bhai thank you so much for this great effort for us.

ameerausman
Автор

Nice Sir Bohut Maja Aya Vs Code ME Calculator Bna Kar❤

gamerpreet
Автор

Maja aa gya harry bhai thank u bhai I like ❤️ gui course

AnujYadav-hdsu