Simple GUI Calculator in Python

Sdílet
Vložit
  • čas přidán 24. 07. 2021
  • Today we build a simple GUI calculator in Python. For the graphical user interface we use tkinter.
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    🐍 The Python Bible Book: www.neuralnine.com/books/
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/
  • Věda a technologie

Komentáře • 192

  • @BrendanBurkartSF
    @BrendanBurkartSF Před 11 měsíci +23

    this was super helpful and really well done! I actually really liked that you had the lambda still in there for the btn_equals...it let us see your debugging process. Thank you!

  • @thatgarryman9400
    @thatgarryman9400 Před 6 měsíci +8

    Literally explained better than half of the programmers in CZcams. Makes sense, explains, doesn't do unnecessary stuff.

  • @wko_
    @wko_ Před 3 lety +22

    Very simple and very useful!
    Thanks for one more project like this!

  • @efogovirtual9635
    @efogovirtual9635 Před 11 měsíci +2

    I appreciate you, this is absolutely useful, nice tutorial

  • @nipoteemus2472
    @nipoteemus2472 Před 2 lety +9

    Thanks for the tutorial! I have that kind of school project where I have to make a representation of your favorite hobby or that stuff! I planned to make it about coding and I'm trying to do 3 softwares for it and this is fricking good idea!

  • @AbubakarMulla23
    @AbubakarMulla23 Před 3 lety +4

    Love your coding bro... Stay going on..

  • @DC_Luxurious_Cars_
    @DC_Luxurious_Cars_ Před rokem

    I really enjoyed this. Thank you very much.

  • @deeparose2926
    @deeparose2926 Před 3 lety +2

    Loved it!!

  • @bonyimakaveli633
    @bonyimakaveli633 Před rokem +4

    Big thanks man. Really appreciate what you do.

  • @yadobeatz359
    @yadobeatz359 Před rokem

    very simle and helpful a lot, thank you a lot

  • @user-mz9ql7oc9j
    @user-mz9ql7oc9j Před rokem +2

    Very simple and very useful!
    Thanks ❤ 🇲🇦

  • @haokaixuan
    @haokaixuan Před 3 lety +8

    love these projects!

  • @tomasg101
    @tomasg101 Před rokem

    Thank you dude, I´m learning Python and this was perfect to achieve new knowledge
    Greetins from Argentina

  • @cannafarmer
    @cannafarmer Před 2 lety +1

    Thank you for the videos I like to scan them quick when i'm stuck

  • @scratchersdotcom9336
    @scratchersdotcom9336 Před rokem +9

    Very nice tutorial. I very well understood. Really appreciate it 👏

  • @arslanuzakov988
    @arslanuzakov988 Před rokem +6

    i really like that thats the first youtube project thats works without error, thank you sir

    • @Lejo1_LV
      @Lejo1_LV Před měsícem

      now i can not agree it dosent wor to me

  • @arnavmeena525
    @arnavmeena525 Před 3 lety +13

    NeuralNine: *Making Calculator and is doing calculations on it*
    Also NeuralNine: Am gonna do the calculations myself. Who needs a calculator?

  • @anonymspro7864
    @anonymspro7864 Před 3 lety +1

    Great bro i was finding this only from a long time.Thanks for uploading in this Content.I'm excited for your next video please upload it as soon as possible :) :) :) :) ;) ;)

  • @Fortniteonly887
    @Fortniteonly887 Před 11 dny

    bro thank you very much. you made my day. keep up

  • @rodinicen689
    @rodinicen689 Před 4 měsíci

    Very nice video! More of this! :D

  • @exxavier1695
    @exxavier1695 Před 9 měsíci

    I love the project it was very useful and helpful thanks

  • @user-wv1kr2pz1q
    @user-wv1kr2pz1q Před rokem

    Interesting explanation ❤

  • @fayazshams-rd3ek
    @fayazshams-rd3ek Před rokem

    Really really really Great i wish you more success ❤❤❤

  • @tortu_nashe
    @tortu_nashe Před 11 měsíci

    nice vid liked n subed , made me feelike programming more

  • @dieelitezwerge7622
    @dieelitezwerge7622 Před rokem +1

    thanks for another very nice video😇😉

  • @tsmghost
    @tsmghost Před 3 lety +3

    Already made that but still learnt something new❤️❤️❤️

  • @sarveshsargunan4914
    @sarveshsargunan4914 Před rokem

    i learned a lot from this video and i did it myself as well

  • @theminecrafttree8913
    @theminecrafttree8913 Před 2 lety

    the best tutorial ever bro u da best

  • @himanshuranjansingh6134

    Thank you man🌻

  • @EBKCS_DHRUV_SHARMA
    @EBKCS_DHRUV_SHARMA Před rokem

    man i love you, best is what i think you are!!!!

  • @rezalapriani1001
    @rezalapriani1001 Před 3 lety

    i learn from your video, thanks you soo much

  • @patibandlalatha7530
    @patibandlalatha7530 Před 7 měsíci

    Very much helpful to the python learners

  • @feliperodrigues3277
    @feliperodrigues3277 Před rokem

    You're the best one to explain, ty so much man

  • @100mikedaniel6
    @100mikedaniel6 Před 3 lety +8

    Stay on the upload grind!

    • @NeuralNine
      @NeuralNine  Před 3 lety +7

      one video every other day! 💪🏻

    • @AlexMuseMatrix
      @AlexMuseMatrix Před 4 měsíci

      Try 4 videos Every day, It's a great schedule 😎@@NeuralNine

  • @lerserk
    @lerserk Před rokem

    19:46 Its the lambda bro!!
    Thank you for this!

  • @maitruong7909
    @maitruong7909 Před 7 měsíci

    Awesome! 10 points

  • @zhangchill1616
    @zhangchill1616 Před 9 měsíci

    Very simple Thank yous

  • @rushikeshmali3057
    @rushikeshmali3057 Před 3 měsíci

    Thanks for beautiful guidens

  • @piklif5278
    @piklif5278 Před rokem

    this helped me so mauch thax

  • @KatherineHunt-bz9fg
    @KatherineHunt-bz9fg Před 7 měsíci +15

    Learning python on a calculator

  • @alirezaahmadivand831
    @alirezaahmadivand831 Před 2 lety

    Thanks a lot 🙏

  • @fzel1
    @fzel1 Před 6 měsíci

    the amount of time he takes to build the calculator is so impressive

  • @RahulKumar-cm1sy
    @RahulKumar-cm1sy Před 2 měsíci

    Thank you sir ❤

  • @Tom-ks9xl
    @Tom-ks9xl Před 6 měsíci

    Fantastic

  • @sithhill
    @sithhill Před rokem +1

    How does this do the actual math portion without telling it to do a math calculation? The other calculator I made doesn't have a GUI but all the code is to specify the actual math method being used versus, all we (you) did was create buttons. I followed along and just don't understand how it's automatically doing the math.

  • @paulmwangi270
    @paulmwangi270 Před rokem

    The tutorial was topnotch

  • @housemajaliwa
    @housemajaliwa Před rokem

    Good stuff

  • @evoamer2686
    @evoamer2686 Před 6 měsíci

    You have made me switch from C# to python my friend

  • @kennethlourisombrog2149
    @kennethlourisombrog2149 Před 6 měsíci

    Nice. Do you think I can include this in my portfolio to apply for a job? I can say that I followed your tutorial and learned from it.

  • @davidianmusic4869
    @davidianmusic4869 Před 10 měsíci

    Thanks!

  • @akshar088
    @akshar088 Před 5 měsíci

    amazing

  • @yoonesaghtaii8991
    @yoonesaghtaii8991 Před 5 měsíci

    thanks bro❤

  • @noir66146
    @noir66146 Před 2 lety

    my kind of tutorial

  • @flowereye3720
    @flowereye3720 Před 2 lety

    Thank you

  • @sianbunny7724
    @sianbunny7724 Před 4 měsíci

    thnx man
    🙏

  • @PCANDPOCO
    @PCANDPOCO Před 2 měsíci

    thank you very much

  • @Victory-py7lp
    @Victory-py7lp Před 4 měsíci +1

    Can someone explain why he uses the .delete first before the .insert? What does that do?

  • @wise_beanss
    @wise_beanss Před rokem

    is it possible to make a delete button? If so how do you do it, cos i have been trying to figure it out for the past week, but still can’t (i’m a beginner btw)

  • @therumblemain
    @therumblemain Před 10 měsíci

    so usefull and hepfull I subsribed this is my 2nd videio watching

  • @tummatantewadonprasit639
    @tummatantewadonprasit639 Před 4 měsíci

    Tysm❤❤😊

  • @akellner2
    @akellner2 Před 8 měsíci

    Thank you for sharing, I wonder how I can implement an %-Button with the correct function. I tried it but I can`t figure it out.

  • @RekhsKitchen
    @RekhsKitchen Před 2 lety

    0:42 when he said nonsense haha

  • @svetlanadelrey973
    @svetlanadelrey973 Před 8 měsíci

    i would love if u explained what are you doing in ur actions

  • @surfineer
    @surfineer Před rokem +2

    Interesting explanation on the eval() functionality. But what alternatives would you suggest for better security?

    • @GeovaniLopesDias
      @GeovaniLopesDias Před rokem +1

      I didn't watched it with audio on, so I don't know what security issues he mentioned, but I was wondering the whole video when would he write the regex code to interpret the string arithmetic expression.
      It'd require some extra functions to substitute the eval() built-in.
      For personal challenge, we could try to code these said extra functions.

    • @skystep2
      @skystep2 Před rokem +1

      I am noob, but I would not allowed letters, only go execute eval if there are no letters and other not allowed symbols

    • @v11r
      @v11r Před 10 měsíci

      You need to implement a tree

  • @brany2920
    @brany2920 Před rokem

    i have tried installing this Tkinter but still wouldnt work on my window 10 or my mac pro. its so confusing i get this error : "ModuleNotFoundError: No module named '_tkinter'" what do i do

  • @anirudhpm7155
    @anirudhpm7155 Před rokem +1

    How can i add √ and on off button could you please help me.

  • @ethan_haymore3907
    @ethan_haymore3907 Před 4 měsíci

    everything worked but the buttons only work individually instead of 1+2 it would just say the number by itself when clicked instead of holding memory. any tips or advice

  • @Void-Dev
    @Void-Dev Před rokem +1

    For the buttons why not just use a definition?

  • @brendanjordan5485
    @brendanjordan5485 Před rokem +4

    Thank you for the video!
    If I want to make it so that I don't have to type a '*' before the parenthesis for the code to recognize that it should multiply, how do I make it so that this code recognizes that 'x(a)", where x and a are any number , are suppose to multiply? Like if I want it to calculate "90/3(1+2)"

    • @jeez8136
      @jeez8136 Před rokem +2

      i was wondering that too so i asked chatgpt and this is what it said:
      To make the code recognize this implicit multiplication, you can add a check in the add_to_calculation function to see if the last symbol in the calculation string is a number, and if so, add the multiplication symbol before adding the parentheses.
      Here is an updated add_to_calculation function that implements this logic:
      def add_to_calculation(symbol):
      global calculation
      if symbol == "(" and calculation != "" and calculation[-1].isdigit():
      calculation += "*"
      calculation += str(symbol)
      text_result.delete(1.0, "end")
      text_result.insert(1.0, calculation)
      With this code, if the user types a number followed by an opening parenthesis, the function will automatically insert a multiplication symbol before the parenthesis. This means that if the user types "90/3(1+2)", the calculation string will become "90/3*(1+2)" before evaluation.

    • @TheRealStrider
      @TheRealStrider Před 11 měsíci

      @@jeez8136
      So I was wondering this as well and have finally made it work behind the scenes without it showing it add the * before the (. Here is the code:
      implicit = list(calculation)
      i = 0
      while i

    • @oadeep
      @oadeep Před 10 měsíci

      thank you so much it works@@TheRealStrider

  • @user-qt4jh1lq6s
    @user-qt4jh1lq6s Před 4 měsíci

    Thanks

  • @Al_X-2005
    @Al_X-2005 Před 5 měsíci

    Now that I can make custom buttons I can finally create the Calculator 2

  • @aradthetyper2101
    @aradthetyper2101 Před 2 lety +3

    brilliant! just one thing. i don't get the part where you put (1.0, "end") after text_result.delete or text_result.insert. what do they mean?

    • @poorvinalavade8651
      @poorvinalavade8651 Před 2 lety

      even i want to know the meaning of those parameters

    • @timmyt1232
      @timmyt1232 Před rokem +5

      In tkinter (for text), delete(first index position, last index position). The 1 is first line. The 0 is before first character. The "end" is to the end of the text. insert(index position, string)

    • @Himlajchan
      @Himlajchan Před 2 měsíci

      @@timmyt1232 Would you mind explaining where this 'end' argument is defined? Tried to look into the source via PyCharm, but couldn't find where this is specified, not even in any documentation that I looked trough. How can I know what other strings are valid for the index parameter?

  • @caw986
    @caw986 Před rokem +1

    hi good video all in all but the code keeps on throwing the error message at me when i perform any calculations

  • @harshalpatil2618
    @harshalpatil2618 Před 10 měsíci

    Super vdo

  • @anakin.gulliver
    @anakin.gulliver Před 2 lety +1

    can you help me?
    I get the error:
    ModuleNotFoundError: No module named 'tkinter'
    when i tri to do the first test run. I cant seem to get it to work on any ide expect on python terminal alone.

    • @LyricZ
      @LyricZ Před 2 lety +1

      import tkinter

  • @iumamaiftikhar
    @iumamaiftikhar Před rokem

    sir i have a problem on line 5 iwrote it correct what should i do

  • @speedev
    @speedev Před 3 lety +1

    Thx.

  • @Knowmemelife
    @Knowmemelife Před 9 měsíci

    Brow what will I do if on calculator I click 1 and the result is always calculation

  • @reskretny20
    @reskretny20 Před 7 měsíci

    he looks like Nacho from Better call Saul

  • @cheesefries6616
    @cheesefries6616 Před rokem

    could anyone explain more about the text_result.delete(1.0, "error") and text_result.insert(1.0, calculation). I'm confused as hell

  • @nellcid7909
    @nellcid7909 Před rokem

    how to fix "text_result" is not defined error?

  • @googlegoogle1610
    @googlegoogle1610 Před 2 lety +2

    i like your video but why not to paste the code in the description

  • @pan_ching
    @pan_ching Před měsícem

    How do you do the copy paste trick??? damn. It seems like it's a shortcut key or somethin' it was so quick ahahahhah

  • @HardeepSingh-ec4zq
    @HardeepSingh-ec4zq Před 4 měsíci

    How can I add percentage button in this program

  • @sepgorut2492
    @sepgorut2492 Před 3 lety +1

    Computerphile has an interesting approach to evaluating equations using functional programming: czcams.com/video/7tCNu4CnjVc/video.html

  • @frigontech
    @frigontech Před rokem

    20:24, do equals without the lambda

  • @ernurernur303
    @ernurernur303 Před rokem

    hey guys , how to add backspace function ? if you know pliss

  • @leadgebrat9880
    @leadgebrat9880 Před rokem

    The delete function is not working... Gives an Attribute error

  • @user-pm5bx5tg4g
    @user-pm5bx5tg4g Před 5 měsíci

    After lambda add to command is not showing in blue colour

  • @jasongonzalez502
    @jasongonzalez502 Před měsícem

    Can anyone explain to me how he navigates the code by highlighting a single character then just skimming it? I'm a bit new to coding and am still learning much. - Thanks!

  • @unknown-cz5yh
    @unknown-cz5yh Před rokem

    error is occuring when i am adding 1+1 how to solve this problem

  • @Tom-ks9xl
    @Tom-ks9xl Před 6 měsíci

    What interface are you using? Looks very good. The standard IDE isn't as nice as this

    • @N7ShepardSR
      @N7ShepardSR Před 6 měsíci

      PyCharm its really good

    • @Tom-ks9xl
      @Tom-ks9xl Před 5 měsíci

      Thank you i found it and installed it right onto linux. It's a very nice interface and handy.

  • @Cheezou.
    @Cheezou. Před 2 lety +1

    Where is the code , i wanna compare with mine pls

  • @sasakovar2936
    @sasakovar2936 Před rokem

    thx, I can flex now xD.

  • @SnowNight
    @SnowNight Před rokem

    intro music name?

  • @jokemiri
    @jokemiri Před rokem

    I just completed this. Is it possible to clear the screen after a result when a new number is keyed? Thank you for the tutorial.

  • @dedehurairrah4345
    @dedehurairrah4345 Před 2 měsíci

    When i click the number are error, can you repair my code?

  • @Hunter-kd4gi
    @Hunter-kd4gi Před 6 měsíci +1

    SyntaxError: expected 'except' or 'finally' block

  • @affenkratzer
    @affenkratzer Před 5 měsíci

    i have also a function if you want to remove one character from the calculation if you made an error typing, but you need an extra delete button for it:
    def remove():
    global calculation
    if calculation:
    calculation = calculation[:-1]
    text_result.delete(1.0, "end")
    text_result.insert(1.0, calculation)
    pass
    pass

    • @Victory-py7lp
      @Victory-py7lp Před 4 měsíci +2

      Thank you so much.

    • @Soo-qd1co
      @Soo-qd1co Před 4 měsíci +1

      thank buddy 🙏

    • @Victory-py7lp
      @Victory-py7lp Před 4 měsíci

      Can you please explain why he .delete came before the .insert?

    • @affenkratzer
      @affenkratzer Před 4 měsíci

      @@Victory-py7lp because of the grid placement you need to change it

  • @mariustrelea5132
    @mariustrelea5132 Před 3 lety +1

    Can you implement it with constants e and π , and also trigonometric functions

    • @flowman8414
      @flowman8414 Před 3 lety

      well do try to do it yourself

    • @mariustrelea5132
      @mariustrelea5132 Před 3 lety

      @@flowman8414 import math has trigonometric functions and also the inverse functions of themselves ?

    • @flowman8414
      @flowman8414 Před 3 lety

      @@mariustrelea5132 yea i think so