Build A Simple Calculator App - Python Tkinter GUI Tutorial #5

Build A Simple Calculator App - Python Tkinter GUI Tutorial #5

Codemy.com

5 лет назад

353,580 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Jan Lochman
Jan Lochman - 11.10.2023 09:06

Hey, why you have placed columnspan parameter and applied it on the Entry widget? The other (button) widgets inherit it?

Ответить
Majid6164 Hashemi
Majid6164 Hashemi - 07.10.2023 20:32

Thanks u🎉

Ответить
John Runner
John Runner - 14.09.2023 11:00

i wonder about lambda function , i never see to use function outside and use inside lambda , can anyone tell me how it work

Ответить
VINH BUB
VINH BUB - 10.09.2023 16:29

width and padx button, how different?

Ответить
Erik de Jong
Erik de Jong - 09.08.2023 13:03

how to fix Tlc/Tk error

Ответить
Maaz zia
Maaz zia - 12.07.2023 13:44

sir my global variable aint working

Ответить
Aneesh Madhavan
Aneesh Madhavan - 09.06.2023 15:31

How to make the tkinter window flexible when maximizing or adjusting the size of the window?

Ответить
2noiembrie83
2noiembrie83 - 28.05.2023 08:09

For python 3.10, with pycharm, in Ubuntu, it's lambda instead of Lambda.

Ответить
sadibou thioye
sadibou thioye - 24.05.2023 14:54

i love this

Ответить
Carlisle Brown
Carlisle Brown - 24.05.2023 14:53

Amazing

Ответить
sadibou thioye
sadibou thioye - 24.05.2023 14:50

gouwatom shivapondiyan

Ответить
Mashal Mokarar
Mashal Mokarar - 01.05.2023 13:35

god bless you men thanks alot ❤❤❤

Ответить
Tshering Lhamo
Tshering Lhamo - 18.04.2023 06:50

Hello. Its from Bhutan. This video really helped me. Kadrinchey!

Ответить
IceTheGameDev
IceTheGameDev - 19.01.2023 22:05

Please continue to make videos, you are truly a great creator and help so many people like me learn to code

Ответить
Luki Puki
Luki Puki - 19.01.2023 01:40

Thanks for the great intro to python. Can't believe my first project worked:)

Can you explain how to limit input to the GUI or easily exclude letters and non 'math' symbols from the keyboard please?

Ответить
I Em Gote
I Em Gote - 29.12.2022 17:38

I´ve been trying to bind the buttons to keys on the keyboard, every time it seems to just type out all the numvers and they keys don't seem to do anything. Any advice?

Ответить
The Mad Magic
The Mad Magic - 29.12.2022 14:08

"its a program, we can build it and that should be cool"
~John

Ответить
Yossi Kally
Yossi Kally - 29.11.2022 17:16

any source code available?

Ответить
FoxMaster99
FoxMaster99 - 19.10.2022 17:49

sus

Ответить
Macdonald Juma
Macdonald Juma - 24.09.2022 17:33

I enjoy how fun you make your lessons, 😃Thank you

Ответить
Bobby Booty
Bobby Booty - 17.08.2022 20:16

Hello ! Could not we have created an Object "Button" instead of copy/paste all these lines ? Thank you

Ответить
Roberto Carlos Farfan Sanchez
Roberto Carlos Farfan Sanchez - 28.07.2022 01:05

ONG

Ответить
Nat Dex
Nat Dex - 27.07.2022 00:24

How’s it going?

Ответить
Niên Trần Đại
Niên Trần Đại - 21.06.2022 12:24

how do you know to set the padx of "=" is 91 ???

Ответить
The Gaming Empire
The Gaming Empire - 13.06.2022 19:28

Can anyone write the code in the description

Ответить
Tim Roust
Tim Roust - 19.05.2022 05:11

Great teaching ! This playlist is paced so well. I've been going in circles trying to get started with Tkinter till now. This gave me a confidence boost ! Thank you!

Ответить
Nässude Kanal
Nässude Kanal - 25.03.2022 23:14

it says that "Lambda is not defined" What Should i do?

Ответить
White Dinamo
White Dinamo - 07.03.2022 20:17

Lesson check. Thanks.

Ответить
Matthew Keen
Matthew Keen - 02.03.2022 17:52

nice..

Ответить
_ storm
_ storm - 25.02.2022 08:41

Hey, could anyone please guide me to how to runs these functions(-,+,/,*) with 3 integers, using Tkinter. Thanks!!!

Ответить
EstifyOffical
EstifyOffical - 05.02.2022 18:01

its says invalid syntax for me. That problem came in when there was lambda: button_click(1))
and that problem says the : is the problem

Ответить
C .F
C .F - 24.01.2022 02:51

😳Is it "Lambda" ? It looks like "Lambda"!! 🧐 Oh no wait, it is "lambda" with "l" not "L" 😓 what a confusing "text_fönt" 🤣

Ответить
Ali Elharras
Ali Elharras - 18.01.2022 00:51

what does the lambda do??

Ответить
ANSH
ANSH - 24.11.2021 06:39

I like your tutorials but i want to know that how can we make that

First when we start a start button will be visible and when we click it the screen changes to this calculator in that screen only not in another screen
So please tell me

And also
Thank You

Ответить
Charlotte Rowe
Charlotte Rowe - 13.10.2021 03:07

I get a syntax error associated with the Lambda; based on some Stack Overflow comments this looks like it's not possible to use in Python 3? I should go try my older version of Python and see if it works there. Not sure how to get around this. OK never mind thanks, I saw your answer about lowercase L in "lambda". But YOUR screen keeps capitalizing them! At least it looks like uppercase.

Ответить
ANSH
ANSH - 05.10.2021 07:35

It would be helpful for us if you write the script in the description too.
But I like your videos.

Ответить
Nnnn
Nnnn - 28.09.2021 14:08

I request you to please slow speaking because we can't understand what you are saying.
My English is weak .

Ответить
User Name
User Name - 09.09.2021 19:42

❤😘😍

Ответить
Jenil Chudgar
Jenil Chudgar - 27.08.2021 19:30

I made it better!
from tkinter import *
root = Tk()
root.title("Calculator")

def click(val):
inputField.insert(END,str(val))
def clear():
inputField.delete(0,END)
def equals():
exp = inputField.get().replace("÷","/").replace("X","*")
clear()
inputField.insert(0,str(eval(exp)))
def backspace():
val = inputField.get()[0:-1]
clear()
inputField.insert(0,val)

inputField=Entry(root,width=30,borderwidth=10)
inputField.grid(row=0,column=0,columnspan=3,padx=20,pady=20)

button_backSpace = Button(root,text="⌫",padx=15,pady=15,command=lambda:backspace()).grid(row=6,column=2)
button_0 = Button(root,text="0",padx=20,pady=20,command=lambda:click("0")).grid(row=6,column=1)
button_equals = Button(root,text="=",padx=20,pady=20,command=lambda:equals()).grid(row=6,column=0)
button_1 = Button(root,text="1",padx=20,pady=20,command=lambda:click("1")).grid(row=5,column=2)
button_2 = Button(root,text="2",padx=20,pady=20,command=lambda:click("2")).grid(row=5,column=1)
button_3 = Button(root,text="3",padx=20,pady=20,command=lambda:click("3")).grid(row=5,column=0)
button_4 = Button(root,text="4",padx=20,pady=20,command=lambda:click("4")).grid(row=4,column=2)
button_5 = Button(root,text="5",padx=20,pady=20,command=lambda:click("5")).grid(row=4,column=1)
button_6 = Button(root,text="6",padx=20,pady=20,command=lambda:click("6")).grid(row=4,column=0)
button_7 = Button(root,text="7",padx=20,pady=20,command=lambda:click("7")).grid(row=3,column=2)
button_8 = Button(root,text="8",padx=20,pady=20,command=lambda:click("8")).grid(row=3,column=1)
button_9 = Button(root,text="9",padx=20,pady=20,command=lambda:click("9")).grid(row=3,column=0)
button_dot = Button(root,text=".",padx=20,pady=20,command=lambda:click(".")).grid(row=2,column=2)
button_clear = Button(root,text="C",padx=20,pady=20,command=lambda:clear()).grid(row=2,column=1)
button_div = Button(root,text="÷",padx=20,pady=20,command=lambda:click("÷")).grid(row=2,column=0)
button_mul = Button(root,text="X",padx=20,pady=20,command=lambda:click("X")).grid(row=1,column=2)
button_minus = Button(root,text="-",padx=20,pady=20,command=lambda:click("-")).grid(row=1,column=1)
button_add = Button(root,text="+",padx=20,pady=20,command=lambda:click("+")).grid(row=1,column=0)

root.mainloop()from tkinter import *
root = Tk()
root.title("Calculator")

def click(val):
inputField.insert(END,str(val))
def clear():
inputField.delete(0,END)
def equals():
exp = inputField.get().replace("÷","/").replace("X","*")
clear()
inputField.insert(0,str(eval(exp)))
def backspace():
val = inputField.get()[0:-1]
clear()
inputField.insert(0,val)

inputField=Entry(root,width=30,borderwidth=10)
inputField.grid(row=0,column=0,columnspan=3,padx=20,pady=20)

button_backSpace = Button(root,text="⌫",padx=15,pady=15,command=lambda:backspace()).grid(row=6,column=2)
button_0 = Button(root,text="0",padx=20,pady=20,command=lambda:click("0")).grid(row=6,column=1)
button_equals = Button(root,text="=",padx=20,pady=20,command=lambda:equals()).grid(row=6,column=0)
button_1 = Button(root,text="1",padx=20,pady=20,command=lambda:click("1")).grid(row=5,column=2)
button_2 = Button(root,text="2",padx=20,pady=20,command=lambda:click("2")).grid(row=5,column=1)
button_3 = Button(root,text="3",padx=20,pady=20,command=lambda:click("3")).grid(row=5,column=0)
button_4 = Button(root,text="4",padx=20,pady=20,command=lambda:click("4")).grid(row=4,column=2)
button_5 = Button(root,text="5",padx=20,pady=20,command=lambda:click("5")).grid(row=4,column=1)
button_6 = Button(root,text="6",padx=20,pady=20,command=lambda:click("6")).grid(row=4,column=0)
button_7 = Button(root,text="7",padx=20,pady=20,command=lambda:click("7")).grid(row=3,column=2)
button_8 = Button(root,text="8",padx=20,pady=20,command=lambda:click("8")).grid(row=3,column=1)
button_9 = Button(root,text="9",padx=20,pady=20,command=lambda:click("9")).grid(row=3,column=0)
button_dot = Button(root,text=".",padx=20,pady=20,command=lambda:click(".")).grid(row=2,column=2)
button_clear = Button(root,text="C",padx=20,pady=20,command=lambda:clear()).grid(row=2,column=1)
button_div = Button(root,text="÷",padx=20,pady=20,command=lambda:click("÷")).grid(row=2,column=0)
button_mul = Button(root,text="X",padx=20,pady=20,command=lambda:click("X")).grid(row=1,column=2)
button_minus = Button(root,text="-",padx=20,pady=20,command=lambda:click("-")).grid(row=1,column=1)
button_add = Button(root,text="+",padx=20,pady=20,command=lambda:click("+")).grid(row=1,column=0)

root.mainloop()

Ответить
مؤسسة رؤية الجنة  | Ruyat Al Jannah Foundation
مؤسسة رؤية الجنة | Ruyat Al Jannah Foundation - 14.08.2021 11:05

bald

Ответить
jeff503pdx
jeff503pdx - 13.08.2021 04:29

Looks nice but how to stylize the calculator?(colors/shapes/etc..)

Ответить
Beast609
Beast609 - 29.07.2021 12:35

num1 = input("Type in the first number: ")
num2 = input("Type in the second number: ")
result = float(num1) + float(num2)
print(result)

Ответить
Matthew Tam
Matthew Tam - 13.07.2021 17:22

Please help...

button_1 = Button(root, text="1", padx=30, pady=25, command=Lambda: button_click(1), font=number_font)
^
SyntaxError: invalid syntax

Ответить
Leif Leoden
Leif Leoden - 06.07.2021 06:48

What version of python is everyone using? I'm using 3.9.2 and getting the following error:

button_1 = Button(root, text="1", padx=40, pady=20, command=Lambda: button_click(1))
^
SyntaxError: invalid syntax

Ответить
Hedonist John
Hedonist John - 30.06.2021 05:53

I keep rewatching because my calculator window is way bigger that yours. My padx and pady are the same

Ответить
sylvester420
sylvester420 - 28.06.2021 20:47

can you share the code?

Ответить