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

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ส.ค. 2024
  • How to Build A Simple Calculator App with TKinter and Python. In this video we'll start to build a simple calculator app using the stuff we've learned from the previous videos.
    In this series I'll show you how to create graphical user interfaces for Python with Tkinter. TKinter comes with Python already, so there's nothing to install!
    ✅ Watch The Other Videos In This Python Playlist:
    bit.ly/2UFLKgj
    ▶️ See More At:
    Codemy.com
    ✅ Join My Facebook Group:
    bit.ly/2GFmOBz
    ✅ Subscribe To My TH-cam Channel:
    bit.ly/2IGzvOR
    ▶️ Learn to Code at Codemy.com
    Take $22 off with coupon code: youtube

ความคิดเห็น • 480

  • @Codemycom
    @Codemycom  4 ปีที่แล้ว +12

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My TH-cam Channel:
    bit.ly/2UFLKgj bit.ly/2IGzvOR
    ▶️ See More At: ✅ Join My Facebook Group:
    Codemy.com bit.ly/2GFmOBz
    ▶️ Learn to Code at Codemy.com ✅ Buy a Codemy T-Shirt!
    Take $30 off with coupon code: youtube1 bit.ly/2VC9WUN

    • @magiconfire
      @magiconfire 4 ปีที่แล้ว +3

      yooooooooooooooo plz say hi plz

  • @letsarray5712
    @letsarray5712 3 ปีที่แล้ว +42

    17:00 if you error syntax you have to replace Lambda to lambda. The syntax is worked than Lambda

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +3

      Never use capital L in lambda...I don't use capital L in the video.

    • @letsarray5712
      @letsarray5712 3 ปีที่แล้ว +6

      @@Codemycom yeah but i look it's large L :d

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      @@letsarray5712 so? the size of it doesn't matter at all, do it in the same way I showed in the video

    • @letsarray5712
      @letsarray5712 3 ปีที่แล้ว +4

      @@Codemycom Oke fine that's not the big problem to me 😂

    • @tiffles699
      @tiffles699 2 ปีที่แล้ว +11

      Thank you, due to the font it looks like its "L" instead of "l", I made that mistake (if using idle, lambda turns orange, Lambda does not)

  • @timmyroust
    @timmyroust 2 ปีที่แล้ว +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!

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว +1

      Happy to hear it!

  • @CShand
    @CShand 4 ปีที่แล้ว +19

    Want to see more about making something like this that scales with resizing.

  • @IceTheCoder
    @IceTheCoder ปีที่แล้ว +3

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

    • @Codemycom
      @Codemycom  ปีที่แล้ว +1

      I have hundreds of videos on my channel and I create more every week.

  • @wrapdoesstuff7614
    @wrapdoesstuff7614 4 ปีที่แล้ว +2

    thanks this video was really helpful and entertaing to both code and watch!

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +2

      Glad it helped!

  • @macdonaldjuma6164
    @macdonaldjuma6164 ปีที่แล้ว

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

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      Glad you're enjoying them!

  • @mrawesome7739
    @mrawesome7739 3 ปีที่แล้ว +7

    I think what helps me learn this is making it my own: changing labels, adding more functions or buttons

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +4

      that's usually the case

    • @ponalvsiki2254
      @ponalvsiki2254 2 ปีที่แล้ว +2

      Make a modern casio fx 580 💪

    • @dragonhunter2264
      @dragonhunter2264 ปีที่แล้ว

      I know this is late but what other type of functions did you add im adding some stuff too but just the division and multiplication wondering if you did anything else?

  • @LhamoID
    @LhamoID ปีที่แล้ว +1

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

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      Glad to hear it!

  • @SomeOne-ec9zx
    @SomeOne-ec9zx 5 หลายเดือนก่อน

    It's a wow what you are doing........keep going

  • @kunxu5612
    @kunxu5612 3 ปีที่แล้ว

    this is also exactly what I demand. thanks.

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Glad you liked it!

  • @umpalumpa2883
    @umpalumpa2883 3 ปีที่แล้ว +2

    Nice video series and good explanation.
    Comment to the commentators: I no sometimes there are weird error messages but I think instead of asking here you could try to figure it out by yourself . It might take some time and can be annoying but at the end of the day you like to learn how to code by yourself and then you'll need to find solutions to upcoming issues.
    Cheers

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +5

      most of coding is googling errors

    • @texxmexxchick
      @texxmexxchick 3 ปีที่แล้ว

      I do this to some extent. I will try any ideas I have of the top of my head, for me this is about 10 -15 mins of re-writing and testing. Once I feel like I'm out of ideas, then I'll google or ask around.

  • @OrlandoGabriel2010
    @OrlandoGabriel2010 4 ปีที่แล้ว +3

    Great work

  • @elchinefa9524
    @elchinefa9524 3 ปีที่แล้ว

    Is not there a way to use for loop? By the way I gonna create a timer for PC with GUI and want to understant how i will use os. system's shutdown commands with tkinter. Of course input must be int.

  • @johnpro2847
    @johnpro2847 5 ปีที่แล้ว +1

    Thanks great help ..

    • @Codemycom
      @Codemycom  5 ปีที่แล้ว

      Happy to help!

  • @nitinjagga2841
    @nitinjagga2841 4 ปีที่แล้ว +1

    You Are Very Good Teacher John Elder Please Make A Video On Doing Webscraping Using Python

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Thanks :-)

  • @musabaltayy6362
    @musabaltayy6362 4 ปีที่แล้ว +7

    you deserve million LIKE for this chain of videos

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +2

      I agree, tell your friends! :-p

  • @toinduino503
    @toinduino503 4 ปีที่แล้ว

    estou gostando muito das aulas parabens profesor

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Glad you're enjoying them!

  • @sadibouthioye6016
    @sadibouthioye6016 ปีที่แล้ว

    i love this

  • @user-vk5xp8wh4e
    @user-vk5xp8wh4e 4 ปีที่แล้ว

    you are a great man

  • @abigailhillen-schiller3641
    @abigailhillen-schiller3641 4 ปีที่แล้ว +4

    Hi John,
    Loving your TKinter tutorials so far.
    I have a question, though. I wrote this loop to create the buttons for 1-9:
    for x in range(1,4):
    y = 10-3*x
    for z in range(y, y+3):
    btn = Button(root, text=z, padx=40, pady=20,
    command=lambda: button_click(z)).grid(row=x, column=z-y)
    The buttons are rendered fine, but when I click them, they all insert the number 3 into the entry box, regardless of the number on the button.
    Changing the lambda as below solved the problem, but I don't understand why:
    lambda q=z: button_click(q)
    Can you explain it?

    • @444444444paok
      @444444444paok 4 ปีที่แล้ว +2

      Because you are in a loop and the lambda function you wrote has no variable i it takes the value of the last iteration. In order to fix it write your lambda like this: lambda q=z: button_click(q) which will work because q is a variable of the lambda so it changes every time you call it. Also its more pythonic to create your buttons with a list instaid of having for loops.

    • @abigailhillen-schiller3641
      @abigailhillen-schiller3641 4 ปีที่แล้ว +1

      @@444444444paok Thanks for the explanation! When you say create buttons with a list, do you mean create each button on a separate line, like in the video, or using a [list]?

    • @444444444paok
      @444444444paok 4 ปีที่แล้ว +1

      ​@@abigailhillen-schiller3641 yeah i mean something like this: num_buttons = [Button(root, text=str(i), width=7, borderwidth=4, pady=15, padx=1, font="Calibri 15 bold", command=lambda i=i: symbol_button_pressed(i)).grid(row=str(3 - (i - 1) // 3), column=str((i - 1) % 3)) for i in range(1, 10)]

    • @abigailhillen-schiller3641
      @abigailhillen-schiller3641 4 ปีที่แล้ว +1

      Great tip, thanks!

    • @hector338
      @hector338 3 ปีที่แล้ว +1

      @@444444444paok That's some really clever indexing for the rows and columns, thanks for the tip.

  • @shukkkursabzaliev1730
    @shukkkursabzaliev1730 4 ปีที่แล้ว +2

    Amazing

  • @ykbroadcast5967
    @ykbroadcast5967 3 ปีที่แล้ว

    super!!! Thanks a Lot..

  • @kerdes_1181
    @kerdes_1181 3 ปีที่แล้ว

    Hello Codemy how can i get an auto selection on a row in a treeview when i get a search
    when i search i want to get the result
    i try tree.selection_set(), but it can't selected row

  • @rodrigopharazz
    @rodrigopharazz 7 หลายเดือนก่อน

    Thank You🙏

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน

      Welcome!

  • @user-ou7jn4eb1z
    @user-ou7jn4eb1z 5 ปีที่แล้ว

    I very like your video.

    • @Codemycom
      @Codemycom  5 ปีที่แล้ว

      Glad you like it :-)

  • @lukipuki4095
    @lukipuki4095 ปีที่แล้ว

    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?

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      I don't have any videos on that

  • @mashalmokarar4817
    @mashalmokarar4817 ปีที่แล้ว

    god bless you men thanks alot ❤❤❤

  • @janlochman1985
    @janlochman1985 9 หลายเดือนก่อน

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

    • @Codemycom
      @Codemycom  9 หลายเดือนก่อน

      no they don't inherit it. We want the entry widget to span the three columns below that hold the other buttons...that's why.

  • @rockleejj123
    @rockleejj123 4 ปีที่แล้ว +1

    Hi, have a problem, at 11:04
    line 25 and 26
    button_0 = Button(root, text='0', padx=40, pady = 20, command = button_add())
    button_add = Button(root, text='+', padx=40, pady = 20, command = button_add())
    seems the button_add redefine the botton_add, it caused error 'Button' object is not callable
    did I type something wrong otherwise.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      shouldn't be any spaces after your padys and commands

    • @parthpatel8192
      @parthpatel8192 4 ปีที่แล้ว

      no its cause u used () in commands

    • @nassudekanal4230
      @nassudekanal4230 2 ปีที่แล้ว

      you cant use parentheses

  • @Another_Look
    @Another_Look 3 ปีที่แล้ว +1

    17:01 What you want is e.insert("end", number)

  • @punishertvv
    @punishertvv 3 ปีที่แล้ว +3

    Thanks sir ...
    This is so simple ..i understood All the things thankyou ...
    Love from INDIA

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      Thanks for watching!

  • @Acuce7ibd468j
    @Acuce7ibd468j 4 ปีที่แล้ว

    hey john !!!! is there any way to make our python app stands alone in mobile without installing a python compiler ??? thank you

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Sure, but it's complicated...

  • @mohammadsakil4050
    @mohammadsakil4050 4 ปีที่แล้ว

    Nice video

  • @tor6953
    @tor6953 8 หลายเดือนก่อน

    Thank you

    • @Codemycom
      @Codemycom  8 หลายเดือนก่อน

      Welcome!

  • @iemgote7249
    @iemgote7249 ปีที่แล้ว

    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?

    • @Codemycom
      @Codemycom  ปีที่แล้ว +1

      I've got several videos on binding on the playlist

  • @ravinduabeygunasekara833
    @ravinduabeygunasekara833 4 ปีที่แล้ว

    what are the units of width and height that we define inside the 'root' function? Is it pixels?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      basically, yes

  • @karlobucic4412
    @karlobucic4412 4 ปีที่แล้ว +6

    Hello from Croatia - 🇭🇷
    First, I just want to say that
    I love your videos. I think that your explaining skills are a great.
    Second - I have a question :
    I built my calculator and everything works perfect but I want to know how the Entry widget recognizes "123" as one number and not as three numbers - "1" , "2" , "3".
    Is that just how it works or what ? Because we don't need to code anything for it to do that.

    • @trininite
      @trininite 4 ปีที่แล้ว +1

      no, python will see it as a string

    • @sulekedelai8564
      @sulekedelai8564 3 ปีที่แล้ว

      Hello From Indonesia

  • @MajidHashemi-rt8le
    @MajidHashemi-rt8le 10 หลายเดือนก่อน

    Thanks u🎉

    • @Codemycom
      @Codemycom  10 หลายเดือนก่อน

      Welcome!

  • @jamesh6224
    @jamesh6224 4 ปีที่แล้ว +1

    Hello, after adding the column span I still have big gaps in-between my columns ?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Weird...double check your code...

    • @jamesh6224
      @jamesh6224 4 ปีที่แล้ว

      @@Codemycom The gaps remain even if i make all the buttons the same size

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@jamesh6224 There has to be something wrong with your code, or something you aren't seeing...

    • @Hyvexx
      @Hyvexx 4 ปีที่แล้ว +1

      This is late but I had the problem with it too. I was on Mac and it turns out that there is a way to tell the tkinter module to move the buttons closer. Just add sticky= "nsew" to the end of all of your .grid() method (example : button_1.grid(row=3, column=0, sticky="nsew")
      stackoverflow.com/questions/45828923/remove-space-between-buttons-in-tkinter#45844991

    • @SmellyNutz
      @SmellyNutz 3 ปีที่แล้ว

      @@Hyvexx You are a LIFESAVER!

  • @whitedinamo
    @whitedinamo 2 ปีที่แล้ว

    Lesson check. Thanks.

  • @leannebourque
    @leannebourque 4 ปีที่แล้ว +4

    when i execute it it says:
    ModuleNotFoundError: No module named 'tkinker'

    • @leannebourque
      @leannebourque 4 ปีที่แล้ว +4

      Nevermind, i spelled it wrong, lol

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +4

      @@leannebourque was just gonna say that lol

    • @digital_shitfest
      @digital_shitfest 3 ปีที่แล้ว

      from tkinter import *
      ^^^
      Use this

  • @davida6146
    @davida6146 3 ปีที่แล้ว

    Wow.... this is more advanced than I need... lol

  • @alielharras3810
    @alielharras3810 2 ปีที่แล้ว +1

    what does the lambda do??

  • @nucleartesla
    @nucleartesla 3 ปีที่แล้ว

    When I came to 8:47 on the video where you made the buttons my buttons where all over the place could you help

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      What did you do differently in your code? If you did what I did, you'd get the same result.

  • @Samuel-yh5lh
    @Samuel-yh5lh 3 ปีที่แล้ว

    after adding the columnspan of the clear and equals button the 0 button didnt show

  • @abdolrezamohseni9787
    @abdolrezamohseni9787 9 หลายเดือนก่อน

    Awesome. Great teaching. Is there any chance to have access to the written codes for each of the video?

    • @Codemycom
      @Codemycom  9 หลายเดือนก่อน

      github.com/flatplanet/Intro-To-TKinter-TH-cam-Course

  • @ansh4786
    @ansh4786 2 ปีที่แล้ว +2

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

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว +1

      The code is here: github.com/flatplanet/Intro-To-TKinter-TH-cam-Course

  • @matthewkeen6281
    @matthewkeen6281 2 ปีที่แล้ว

    nice..

  • @aneeshmadhavan2903
    @aneeshmadhavan2903 ปีที่แล้ว +1

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

    • @Codemycom
      @Codemycom  ปีที่แล้ว

      Sorry, I don't know what you mean by flexible

  • @nelsondarwinpaktech3954
    @nelsondarwinpaktech3954 4 ปีที่แล้ว

    great

  • @Hawatt11
    @Hawatt11 2 ปีที่แล้ว

    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.

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      My screen does not capitalize them lol that's what a lowercase l looks like in sublime...

  • @crossfarm4146
    @crossfarm4146 4 ปีที่แล้ว

    can you quickly explain a little more what e.insert(0,number) requires the 0? is it a boolean value of some sort?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      think of a python list...they are indexed...the first index number is 0. So we want to delete from zero to some number in the box.

  • @gpecs
    @gpecs 7 หลายเดือนก่อน

    Nice tutorials. Instead of running the code everytime, is there a way TK gui can automatic reload after saving in vscode?

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      no

  • @digital-artefakt
    @digital-artefakt 4 ปีที่แล้ว

    Hello, can you explain me why do you have to enter two arguments,like e.insert(0, number)? or (0,END)

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      because you can delete certain characters in the entry box..so it's a range of all the characters in the entry box

    • @digital-artefakt
      @digital-artefakt 4 ปีที่แล้ว

      @@Codemycom oh, it is simple logic when you put it that way. Thank you on your fast answer!

  • @Harish-ou4dy
    @Harish-ou4dy 4 ปีที่แล้ว +3

    in my computer Lambda gave syntax error, lambda with small l works though

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      Yeah, it's never supposed to be capital L in lambda. I do lowercase in the video.

    • @ichabodsescape1885
      @ichabodsescape1885 4 ปีที่แล้ว

      @@Codemycom It got me too the video looks like upper case L

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@ichabodsescape1885 Yeah, I hate that sublime does that

    • @KodiLearn
      @KodiLearn 4 ปีที่แล้ว +2

      Use PyCharm. 😀

  • @adarsht6266
    @adarsht6266 4 ปีที่แล้ว

    Yes it's is very nice
    Please share more videos

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      I release new videos every day

    • @adarsht6266
      @adarsht6266 4 ปีที่แล้ว

      @@Codemycom thanks friend interesting for coding

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@adarsht6266 no problem

    • @adarsht6266
      @adarsht6266 4 ปีที่แล้ว

      Can you connect with us to clarify doubts?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@adarsht6266 People who purchase membership to my site can ask questions about the videos and I answer them. I don't do consulting outside of my courses tho.

  • @sunilkjha3638
    @sunilkjha3638 4 ปีที่แล้ว

    Hello John.
    What does END do in e.delete(0, END)??

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +2

      Think of it as a python list...we're saying delete everything from position 0, to the END of the list.

    • @sunilkjha3638
      @sunilkjha3638 4 ปีที่แล้ว

      @@Codemycom Thank you John. And is it the same in e.insert(0, number)? Does it mean that print everything from 0 to the number entered. Or am I wrong?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      @@sunilkjha3638 Basically, yes

  • @shauryagoyal911
    @shauryagoyal911 4 ปีที่แล้ว

    i am getting this error
    Exception in Tkinter callback
    Traceback (most recent call last):
    File "C:\Users\GEETIKA\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
    File "D:\tkinter\Project 1 - Calculator.py", line 38, in
    button_8 = Button(root, text = "8", padx=40, pady=20, command = lambda: button_click(8))
    TypeError: button_click() takes 0 positional arguments but 1 was given
    pls tell

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      You're passing 8 into your button_click function. Does your button_click function code accept arguments?

  • @_storm4963
    @_storm4963 2 ปีที่แล้ว

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

  • @ansh4786
    @ansh4786 2 ปีที่แล้ว +1

    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

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว +1

      Use frames or tabs

  • @johannesberger8641
    @johannesberger8641 3 ปีที่แล้ว

    Imo a cleaner and (more) pythonic way of defining all the buttons is
    number_buttons = [ Button( root, text=str(i%10), padx=40, pady=20, command=(lambda j=i : button_click(j%10)) ) for i in range(1, 11)]
    Then, to put them on the grid
    for i in range(10):
    number_buttons[i].grid(row=i//3+1, column=i%3)

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +2

      whatever floats your boat

    • @realityfirst5585
      @realityfirst5585 29 วันที่ผ่านมา

      @@Codemycom Ive been enjoying your videos until I started reading your responses. I have to say they arent very professional, Iike this one above. I hope you have grown to be more understanding in the last 3 yrs!

  • @themeow6190
    @themeow6190 3 ปีที่แล้ว

    hey, for some reason when i try to do the e.get, it says there is no attribute called get, can you plez help me

    • @zeyadabbood8401
      @zeyadabbood8401 3 ปีที่แล้ว +1

      do the grid in a new line and it will solve the problem. for example:
      e = Entry(root)
      e.grid(row=0, column=0)
      instead of
      e = Entry (root).grid(row=0, column=0)

    • @fisherman23gp
      @fisherman23gp 3 ปีที่แล้ว

      @@zeyadabbood8401 Bless you

  • @RATANAGARWALITINFORMER
    @RATANAGARWALITINFORMER 3 ปีที่แล้ว

    v helpping

  • @christianh2890
    @christianh2890 4 ปีที่แล้ว

    Can anyone explain why lambda should be used? Why can I not just call button_click function with the correct number?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Try it and see. Tkinter doesn't allow you to pass things through a command, but it does allow it if you use a lambda

  • @gautamkappagal
    @gautamkappagal 3 ปีที่แล้ว

    Hello sir! Thanks for the video, very helpful.
    I've encountered a problem. Before this, I tried the 'Click Me!' Box. Even after copying down the entire same thing of the calculator code, I still get the 'Enter your name' and 'Click Me!' box. How do I change that? Please help me.

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      Rewatch the video and follow along exactly.

    • @_KaranRajS
      @_KaranRajS 2 ปีที่แล้ว

      I think u have run the previous file. Check the file and run or else mistake in code

  • @atoparis
    @atoparis 3 ปีที่แล้ว +1

    I am stuck with this... went through the whole list of comments but still have the issue:
    butt_1 = Button(root, text="1", padx=40, pady=20, command=lambda: butt_click(1))
    However when I click the button it says object not callable

    • @atoparis
      @atoparis 3 ปีที่แล้ว +1

      oh I see my error... I had a button named butt_click later in the code... fixed... leaving the comment in case it helps anyone

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@atoparis Also, you can't padx and pady in the same place you defined the button.

  • @gustavbrolin623
    @gustavbrolin623 4 ปีที่แล้ว

    How did you open your program?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      What do you mean? Open what?

  • @mariogamer587
    @mariogamer587 4 ปีที่แล้ว +2

    How you run your code, I can't run my code in sublime text?? Good video!

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +4

      I'm not running the code in Sublime text. I'm using the git bash terminal that I downloaded.
      git-scm.com/downloads

    • @mariogamer587
      @mariogamer587 4 ปีที่แล้ว +1

      @@Codemycom Ty I'll try that :]

    • @mariogamer587
      @mariogamer587 4 ปีที่แล้ว +1

      @@Codemycom I just get an error:
      $ python calculator.py
      bash: python: command not found
      any solution?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      @@mariogamer587 you didn't add python to path when you installed it. Reinstall it, check the box that says add python to path.

    • @mariogamer587
      @mariogamer587 4 ปีที่แล้ว +1

      @@Codemycom ok ty I added it through settings😊

  • @user-mj5jd1ix8d
    @user-mj5jd1ix8d 2 หลายเดือนก่อน

    Hi, I have SyntaxError: positional argument follows keyword argument. why

    • @Codemycom
      @Codemycom  2 หลายเดือนก่อน

      Because you typed the code wrong... compare it to the video to discover what you did differently.

  • @sourabhdeshpande2112
    @sourabhdeshpande2112 3 ปีที่แล้ว

    in before lecture after button defining we put it button.pack() why it is not put in this lecture

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      In this video we're using the .grid() system instead of .pack() grid is used when you need more precision placing your widgets.

  • @AugusSousa
    @AugusSousa 5 ปีที่แล้ว

    Hi, I have a problem with "e.delete(0, END)" says "END is not defined". :(

    • @Codemycom
      @Codemycom  5 ปีที่แล้ว

      weird...try e.delete(0, tk.END)
      also...is the 0 a zero? Or did you type a capital O letter?

    • @AugusSousa
      @AugusSousa 5 ปีที่แล้ว

      @@Codemycom thanks for replying, I typed zero, and the "tk.END" solved the problem, thanks a lot. Nice video btw.

    • @Codemycom
      @Codemycom  5 ปีที่แล้ว

      @@AugusSousa oh cool, glad it worked!

  • @program_brain
    @program_brain 3 ปีที่แล้ว

    What is meaning for lambda?
    Why we have to use it here sir?
    I am beginner for python...

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +2

      tkinter won’t allow you to pass parameters to functions with commands unless you use a lambda

  • @grelstkoning9373
    @grelstkoning9373 3 ปีที่แล้ว

    Not really sure what the return does in def

  • @leifleoden5464
    @leifleoden5464 3 ปีที่แล้ว

    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

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      The version is irrelevant. The l in lambda needs to be lowercase

  • @developershub4339
    @developershub4339 3 ปีที่แล้ว

    how do you save the calculator built as an app.

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      I have a video on making exe files in the playlist

  • @mostafatud12
    @mostafatud12 3 ปีที่แล้ว

    hi, i wrote the code exactly as the tutorial but it have me this:
    button_3=Button(root,text="3",padx=40,pady=20,command=lambda:button_click(3))
    TypeError: 'Button' object is not callable

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      that's not exactly as the tutorial at all. You can't padx and pady where you define the button.

  • @sarahlewis7859
    @sarahlewis7859 4 ปีที่แล้ว

    I've done the code the same as you have but whenever i click on a number button it says "TypeError: button_click() takes 0 positional argument but 1 was given" I have no idea what this means please help o_o

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      then you haven't done the code the same as me. Check for typos...

    • @mrawesome7739
      @mrawesome7739 3 ปีที่แล้ว

      When you originally defined button click, you probably didn't put anything between the parenthesis. The correct code should be
      def button_click(number):

  • @dumidupramith3881
    @dumidupramith3881 4 ปีที่แล้ว

    good

  • @khizaridrees1758
    @khizaridrees1758 3 ปีที่แล้ว

    Does the Capital L of lambda executed by your interpreter

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      No, it's a lowercase l not capital L

  • @easycodemustapha9610
    @easycodemustapha9610 3 ปีที่แล้ว

    Hey thanks i need just one more weak and i done wth python by the way i dont a pc so i use pythonista ipad 4 ios : 10.3.3 34bit

  • @RinksRides
    @RinksRides 4 ปีที่แล้ว +5

    I smashed said "LIKE" button below, now my screen is broken... THANKS!

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +2

      Life is risk! lol

    • @Mkz32
      @Mkz32 4 ปีที่แล้ว +1

      U smashed the screen then got a syntax error anyways Good vid keep it up

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@Mkz32 too funny!

  • @adebolaokanlawonsaseyi6655
    @adebolaokanlawonsaseyi6655 4 ปีที่แล้ว

    Hello, how do i increase the height of the calculator screen. It seems i can only adjust the width?. I tried increasing the height and got the following error:
    tkinter.TclError: unknown option "-height"

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Do you mean the entry box? You increase the font size: font=("Helvetica", 20)

    • @adebolaokanlawonsaseyi6655
      @adebolaokanlawonsaseyi6655 4 ปีที่แล้ว

      @@Codemycom yes entry box, would ("Arial" 20) also work?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว +1

      @@adebolaokanlawonsaseyi6655 Try it and see. You could have just tried it faster than it took to ask me.

    • @adebolaokanlawonsaseyi6655
      @adebolaokanlawonsaseyi6655 4 ปีที่แล้ว

      @@Codemycom Thank you, it worked.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@adebolaokanlawonsaseyi6655 sweet

  • @cookie-hg2ic
    @cookie-hg2ic 4 ปีที่แล้ว +3

    I kept getting the same error but figured out where i buggered up.
    i kept receiving this message: "TypeError: 'Button' object is not callable"
    this was because i skipped the step where you renamed the button function, from 'button_add' to 'button_click'.
    at the time I thought the name change was just an aesthetic preference.
    which caused a problem with another line where a button was named 'button_add' (the button planned for
    i didn't notice the problem because the name was buried with the equals and clear buttons,
    thought id mention my troubles in case somebody else stumbles on the same stump

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Coolio

    • @therealdoc
      @therealdoc 4 ปีที่แล้ว

      Glad I found this comment. Was wondering how I fucked up and now I know where.

  • @brianmoreira7578
    @brianmoreira7578 4 ปีที่แล้ว

    16:30 when I use lambda the GUI launches but when I click a number I get an error
    TypeError: 'Button' object is not callable
    I don't understand cus I'm using lamda the same way he is.
    Please help!😥

    • @brianmoreira7578
      @brianmoreira7578 4 ปีที่แล้ว

      I think it's because I've named my Button button1.
      I've noticed I have no error when I name it btn1 or button_1(like he did).
      Really wish he would've said something lol.
      But I'm going to see what happens when I change the rest of the Code.

    • @brianmoreira7578
      @brianmoreira7578 4 ปีที่แล้ว

      Yea that was it.
      The Button cannot be named 'button1' or 'button' or 'Button'

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      yep

    • @guyincognito5614
      @guyincognito5614 3 ปีที่แล้ว

      omg, thank god.
      Edit: having the same problem

  • @themadmagic5019
    @themadmagic5019 ปีที่แล้ว

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

  • @bb-ur2dk
    @bb-ur2dk 3 ปีที่แล้ว

    we are using padx= 50 or 60 some number what is the number i mean units 50mm of 50 spaces

  • @chanero-u8z
    @chanero-u8z หลายเดือนก่อน +2

    I just try it myself. In the end , the result is a little bad, but I have finish it.

    • @chanero-u8z
      @chanero-u8z หลายเดือนก่อน

      The tutorials are very useful ❤❤❤

    • @Codemycom
      @Codemycom  หลายเดือนก่อน

      Glad you enjoy them!

  • @gpecs
    @gpecs 7 หลายเดือนก่อน

    why is tkinter gui not loading automatically why do i need to re-run it everytime i make changes.

    • @Codemycom
      @Codemycom  7 หลายเดือนก่อน +1

      that's how all coding works

  • @nientranai1669
    @nientranai1669 2 ปีที่แล้ว

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

    • @Codemycom
      @Codemycom  2 ปีที่แล้ว

      Trial and error

  • @mhingjhangang2015
    @mhingjhangang2015 4 ปีที่แล้ว

    why 0? in the first coordinate under the button_click?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      0 is the first item in a python list

  • @rexsoosan303
    @rexsoosan303 4 ปีที่แล้ว +1

    from tkinter import *
    import math
    root= Tk()
    root.title("Simple Calc")
    e=Entry(root,width=40,borderwidth=5).grid(row=0,column=0,columnspan=4,padx=30,pady=10)
    def Button_click(number):
    e.delete(0,tk.END)
    e.insert(0,number)
    #defining Buttons
    button1= Button(root,text="1",padx=30,pady=30,command=lambda: Button_click(1)).grid(row=4,column=0)
    button2= Button(root,text="2",padx=30,pady=30,command=lambda: Button_click(2)).grid(row=4,column=1)
    button3= Button(root,text="3",padx=30,pady=30,command=lambda: Button_click(3)).grid(row=4,column=2)
    button4= Button(root,text="4",padx=30,pady=30,command=lambda: Button_click(4)).grid(row=5,column=0)
    button5= Button(root,text="5",padx=30,pady=30,command=lambda: Button_click(5)).grid(row=5,column=1)
    button6= Button(root,text="6",padx=30,pady=30,command=lambda: Button_click(6)).grid(row=5,column=2)
    button7= Button(root,text="7",padx=30,pady=30,command=lambda: Button_click(7)).grid(row=6,column=0)
    button8= Button(root,text="8",padx=30,pady=30,command=lambda: Button_click(8)).grid(row=6,column=1)
    button9= Button(root,text="9",padx=30,pady=30,command=lambda: Button_click(9)).grid(row=6,column=2)
    button10= Button(root,text="+",padx=30,pady=30,command=lambda: Button_click()).grid(row=4,column=3)
    button11= Button(root,text="-",padx=30,pady=30,command=lambda: Button_click()).grid(row=5,column=3)
    button12= Button(root,text="*",padx=30,pady=30,command=lambda: Button_click()).grid(row=5,column=4)
    button13= Button(root,text="/",padx=30,pady=30,command=lambda: Button_click()).grid(row=4,column=4)
    button14= Button(root,text="0",padx=30,pady=30,command=lambda: Button_click(0)).grid(row=6,column=3)
    button15= Button(root,text=".",padx=30,pady=30,command=lambda: Button_click()).grid(row=6,column=4)
    button16= Button(root,text="Enter",padx=60,pady=20,command=lambda: Button_click()).grid(row=7,column=0,columnspan=2)
    button17= Button(root,text="Clear",padx=60,pady=20,command=lambda: Button_click()).grid(row=7,column=2,columnspan=2)
    root.mainloop()

  • @deepanshumohan7777
    @deepanshumohan7777 4 ปีที่แล้ว

    I am facing issue while entering a new number with result already present in the input box (concatenation issue). How to resolve it?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      Without knowing what you are doing or what your code is, I can't guess.

    • @deepanshumohan7777
      @deepanshumohan7777 4 ปีที่แล้ว

      @@Codemycom I am working on Simple calculator. Whenever I type a new number, it gets concatenated with the previous result instead of clearing it.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@deepanshumohan7777 My answer to you doesn't change...

  • @beast6092
    @beast6092 3 ปีที่แล้ว +1

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

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      That won't work in tkinter

    • @beast6092
      @beast6092 3 ปีที่แล้ว +1

      @@Codemycom Yeah, just realized it... it works in Python tho

    • @Algeriawindows69
      @Algeriawindows69 10 หลายเดือนก่อน

      thats a console application

  • @fonzyurriquia8640
    @fonzyurriquia8640 3 ปีที่แล้ว

    i use the "lambda" and when i run it, the terminal says "Syntax Error: Invalid Syntax". What do i need to do?

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว +1

      lowercase l in lambda

    • @fonzyurriquia8640
      @fonzyurriquia8640 3 ปีที่แล้ว

      @@Codemycom thank you. you're the best

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      @@fonzyurriquia8640 you’re welcome

  • @yuvithegreat3878
    @yuvithegreat3878 4 ปีที่แล้ว

    I am using .place() to place the entry and buttons but it is END is not defined. Can u help Me?

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      I never use place

    • @yuvithegreat3878
      @yuvithegreat3878 4 ปีที่แล้ว

      @@Codemycom Ok. Il try to use .grid() method.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      @@yuvithegreat3878 cool

  • @rexsoosan303
    @rexsoosan303 4 ปีที่แล้ว

    is there anything wrong. number is not coming on the entry screen

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      probably...check your code :-p

  • @mindset873
    @mindset873 4 ปีที่แล้ว

    How can I subscribe only 27 $ to be accessible to all online courses. Please show me how. I visited the site but did not see it in front of computer screen.

    • @Codemycom
      @Codemycom  4 ปีที่แล้ว

      codemy.com/membership-account/membership-checkout/?level=1
      Add the coupon code and click the apply button

  • @username9258
    @username9258 2 ปีที่แล้ว

    ❤😘😍

  • @doandoan8728
    @doandoan8728 3 ปีที่แล้ว

    I am getting error with this code. Please help me
    File "", line 11
    button_1=Button(root, text="1",padx=40,pady=20, command=Lambda:button_click(1))
    ^
    SyntaxError: invalid syntax

    • @Codemycom
      @Codemycom  3 ปีที่แล้ว

      the L in lambda needs to be lowercase