Simple GUI Calculator in Python

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024
  • 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...
    💻 The Algorithm Bible Book: www.neuralnine...
    👕 Programming Merch: www.neuralnine...
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine...
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/Neu...
    🎙 Discord: / discord
    🎵 Outro Music From: www.bensound.com/

Комментарии • 204

  • @thatgarryman9400
    @thatgarryman9400 10 месяцев назад +11

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

  • @BrendanBurkartSF
    @BrendanBurkartSF Год назад +29

    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!

  • @arnavmeena525
    @arnavmeena525 3 года назад +17

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

  • @lerserk
    @lerserk Год назад +2

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

  • @100mikedaniel6
    @100mikedaniel6 3 года назад +8

    Stay on the upload grind!

    • @NeuralNine
      @NeuralNine  3 года назад +8

      one video every other day! 💪🏻

    • @AlexMuseMatrix
      @AlexMuseMatrix 8 месяцев назад

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

  • @arslanuzakov988
    @arslanuzakov988 2 года назад +6

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

    • @Lejo1_LV
      @Lejo1_LV 5 месяцев назад

      now i can not agree it dosent wor to me

  • @wko_
    @wko_ 3 года назад +22

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

  • @nipoteemus2472
    @nipoteemus2472 2 года назад +10

    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!

  • @tsmghost
    @tsmghost 3 года назад +3

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

  • @AbhayGupta-oz1ix
    @AbhayGupta-oz1ix 3 месяца назад

    This is what i was looking for. Thanks to tutor.

  • @shaunakwasker20
    @shaunakwasker20 Месяц назад

    super helpful and clear, thanks a lot

  • @johnbishoppp
    @johnbishoppp 13 дней назад

    Why not make a class with attributes for the number, row and column, then make a function for creating the button and run it in a for loop.
    This is how I did it, to save time and not repeat code.
    I couldn't figure out how to make the loop also name the buttons incrementally (i.e. btn_1, then btn_2) so I had to type that manually.
    Also had to manually type out the code for equals and clear as the command was different to the others.
    Would love your thoughts.

  • @AbubakarMulla23
    @AbubakarMulla23 3 года назад +4

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

  • @affenkratzer
    @affenkratzer 8 месяцев назад

    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

    • @Veestar4u
      @Veestar4u 8 месяцев назад +2

      Thank you so much.

    • @Soo-qd1co
      @Soo-qd1co 8 месяцев назад +1

      thank buddy 🙏

    • @Veestar4u
      @Veestar4u 8 месяцев назад

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

    • @affenkratzer
      @affenkratzer 8 месяцев назад

      @@Veestar4u because of the grid placement you need to change it

  • @Tdahandaluz.
    @Tdahandaluz. 2 месяца назад +1

    I've always wanted to learn to program and this video helped me understand that my biggest enemy is going to be my dyslexia xD

  • @haokaixuan
    @haokaixuan 3 года назад +8

    love these projects!

  • @fzel1
    @fzel1 9 месяцев назад

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

  • @patibandlalatha7530
    @patibandlalatha7530 11 месяцев назад

    Very much helpful to the python learners

  • @efogovirtual9635
    @efogovirtual9635 Год назад +2

    I appreciate you, this is absolutely useful, nice tutorial

  • @MAhmed12_5
    @MAhmed12_5 4 месяца назад

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

  • @القراءةمفتاحالعلم

    Very simple and very useful!
    Thanks ❤ 🇲🇦

  • @EBKCS_DHRUV_SHARMA
    @EBKCS_DHRUV_SHARMA Год назад

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

  • @deeparose2926
    @deeparose2926 3 года назад +2

    Loved it!!

  • @yadobeatz359
    @yadobeatz359 Год назад

    very simle and helpful a lot, thank you a lot

  • @rodinicen689
    @rodinicen689 8 месяцев назад

    Very nice video! More of this! :D

  • @ChudiO
    @ChudiO 3 месяца назад

    Really good tutorial, has helped improve my Python knowledge 😊

  • @cannafarmer
    @cannafarmer 2 года назад +1

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

  • @DC_Luxurious_Cars_
    @DC_Luxurious_Cars_ Год назад

    I really enjoyed this. Thank you very much.

  • @scratchersdotcom9336
    @scratchersdotcom9336 2 года назад +9

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

  • @hemanmoriya8237
    @hemanmoriya8237 8 месяцев назад +1

    I made the project the completely but I didn't learned many things from it because it was copy paste time type program for me .

    • @Soo-qd1co
      @Soo-qd1co 8 месяцев назад

      which code editor did you use? I used codesandbox and don't show the pop up page for blank page for...
      import tkinter as tk
      calculation = ""
      def add_to_calculation(symbol):
      pass
      def evaluate_calculation():
      pass
      def clear_field():
      pass
      root = tk.Tk()
      root.geometry("300x275")
      root.mainloop()
      and shows up
      Traceback (most recent call last):
      File "calculator.py", line 18, in
      root = tk.Tk()
      File "/usr/local/lib/python3.8/tkinter/__init__.py", line 2270, in __init__
      self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
      _tkinter.TclError: no display name and no $DISPLAY environment variable

    • @hemanmoriya8237
      @hemanmoriya8237 8 месяцев назад

      @@Soo-qd1co I used pycharm for python development

  • @evoamer2686
    @evoamer2686 10 месяцев назад

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

  • @tomasg101
    @tomasg101 Год назад

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

  • @kennethlourisombrog2149
    @kennethlourisombrog2149 10 месяцев назад

    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.

  • @sithhill
    @sithhill Год назад +5

    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.

    • @johnbishoppp
      @johnbishoppp 13 дней назад

      I think it's the eval() function that's doing the math. At 5:30 he mentions that the eval function will evaluate both mathematical equations as well as code.

  • @theminecrafttree8913
    @theminecrafttree8913 2 года назад

    the best tutorial ever bro u da best

  • @paulmwangi270
    @paulmwangi270 Год назад

    The tutorial was topnotch

  • @bonyimakaveli633
    @bonyimakaveli633 Год назад +4

    Big thanks man. Really appreciate what you do.

  • @maitruong7909
    @maitruong7909 11 месяцев назад

    Awesome! 10 points

  • @brendanjordan5485
    @brendanjordan5485 Год назад +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 Год назад +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 Год назад

      @@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 Год назад

      thank you so much it works@@TheRealStrider

  • @dieelitezwerge7622
    @dieelitezwerge7622 Год назад +1

    thanks for another very nice video😇😉

  • @svetlanadelrey973
    @svetlanadelrey973 11 месяцев назад

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

  • @exxavier1695
    @exxavier1695 Год назад

    I love the project it was very useful and helpful thanks

  • @zhangchill1616
    @zhangchill1616 Год назад

    Very simple Thank yous

  • @tortu_nashe
    @tortu_nashe Год назад

    nice vid liked n subed , made me feelike programming more

  • @YukiArtsandCrafts
    @YukiArtsandCrafts Год назад

    Interesting explanation ❤

  • @anonymspro7864
    @anonymspro7864 3 года назад +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 :) :) :) :) ;) ;)

  • @fayazshams-rd3ek
    @fayazshams-rd3ek Год назад

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

  • @riascho
    @riascho Год назад +2

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

    • @GeovaniLopesDias
      @GeovaniLopesDias Год назад +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 Год назад +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 Год назад

      You need to implement a tree

  • @Tom-ks9xl
    @Tom-ks9xl 9 месяцев назад

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

    • @N7ShepardSR
      @N7ShepardSR 9 месяцев назад

      PyCharm its really good

    • @Tom-ks9xl
      @Tom-ks9xl 9 месяцев назад

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

  • @sarveshsargunan4914
    @sarveshsargunan4914 Год назад

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

  • @emitaylorb52
    @emitaylorb52 2 месяца назад

    So wonderful

  • @rezalapriani1001
    @rezalapriani1001 3 года назад

    i learn from your video, thanks you soo much

  • @aradthetyper2101
    @aradthetyper2101 2 года назад +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 2 года назад

      even i want to know the meaning of those parameters

    • @timmyt1232
      @timmyt1232 2 года назад +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 6 месяцев назад

      @@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?

  • @Veestar4u
    @Veestar4u 8 месяцев назад +1

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

  • @RahulKumar-cm1sy
    @RahulKumar-cm1sy 6 месяцев назад

    Thank you sir ❤

  • @p98976
    @p98976 Год назад

    this helped me so mauch thax

  • @himanshuranjansingh6134
    @himanshuranjansingh6134 3 года назад

    Thank you man🌻

  • @feliperodrigues3277
    @feliperodrigues3277 Год назад

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

  • @y7365mVVHsK9J
    @y7365mVVHsK9J 2 месяца назад

    Thanks bro 🧑‍💻🧑‍💻

  • @noir66146
    @noir66146 2 года назад

    my kind of tutorial

  • @ayuzshh
    @ayuzshh Год назад

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

  • @soufatldude700
    @soufatldude700 7 месяцев назад +1

    do you need pycharm for this, or can you use the normal python application?

  • @anirudhpm7155
    @anirudhpm7155 Год назад +1

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

  • @ethan_haymore3907
    @ethan_haymore3907 8 месяцев назад

    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

  • @jasongonzalez502
    @jasongonzalez502 4 месяца назад

    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!

  • @Void-Dev
    @Void-Dev Год назад +1

    For the buttons why not just use a definition?

  • @akellner2
    @akellner2 Год назад

    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.

  • @pan_ching
    @pan_ching 5 месяцев назад +1

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

  • @KatherineHunt-bz9fg
    @KatherineHunt-bz9fg 11 месяцев назад +24

    Learning python on a calculator

  • @Al_X-2005
    @Al_X-2005 9 месяцев назад

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

  • @Hunter-kd4gi
    @Hunter-kd4gi 9 месяцев назад +1

    SyntaxError: expected 'except' or 'finally' block

  • @caw986
    @caw986 2 года назад +1

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

  • @davidianmusic4869
    @davidianmusic4869 Год назад

    Thanks!

  • @PCANDPOCO
    @PCANDPOCO 6 месяцев назад

    thank you very much

  • @mariustrelea5132
    @mariustrelea5132 3 года назад +1

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

    • @flowman8414
      @flowman8414 3 года назад

      well do try to do it yourself

    • @mariustrelea5132
      @mariustrelea5132 3 года назад

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

    • @flowman8414
      @flowman8414 3 года назад

      @@mariustrelea5132 yea i think so

  • @frigontech
    @frigontech Год назад

    20:24, do equals without the lambda

  • @housemajaliwa
    @housemajaliwa Год назад

    Good stuff

  • @srshivam96
    @srshivam96 26 дней назад

    Not working now it says TypeError: 'float' object is not subscriptable whenever i press a button

  • @yoonesaghtaii8991
    @yoonesaghtaii8991 8 месяцев назад

    thanks bro❤

  • @Tom-ks9xl
    @Tom-ks9xl 10 месяцев назад

    Fantastic

  • @googlegoogle1610
    @googlegoogle1610 3 года назад +2

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

  • @SahilPatel-f4u
    @SahilPatel-f4u 8 месяцев назад

    After lambda add to command is not showing in blue colour

  • @brany2920
    @brany2920 Год назад

    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

  • @VRplayerYT
    @VRplayerYT 5 месяцев назад

    when you put root = tk.Tk() it worked perfectly for you but for me it's says AttributeError: module 'tkinter' has no attribute 'tk'

    • @zainnusairat7745
      @zainnusairat7745 4 месяца назад

      did u import tkinter as tk? otherwise u would have to write tkinter.Tk(), u should import it as tk not to waste time

  • @kingkoller1503
    @kingkoller1503 10 месяцев назад

    Great tutorial!
    But in my case (I don't know why) I have to use lambda for all functions so that it would work. And also the result of the previous calculation isn't transferred to the new one. Does anybody know what's wrong?

  • @wise_beanss
    @wise_beanss Год назад

    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)

  • @anakin.gulliver
    @anakin.gulliver 2 года назад +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 2 года назад +1

      import tkinter

  • @leadgebrat9880
    @leadgebrat9880 Год назад

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

  • @alirezaahmadivand831
    @alirezaahmadivand831 2 года назад

    Thanks a lot 🙏

  • @cheesefries6616
    @cheesefries6616 2 года назад

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

  • @HardeepSingh-ec4zq
    @HardeepSingh-ec4zq 7 месяцев назад

    How can I add percentage button in this program

  • @gooddaywithme7986
    @gooddaywithme7986 Месяц назад

    thank you so much 😭😭😭😭🙏🙏🙏🙏

  • @rekhNZ
    @rekhNZ 3 года назад +1

    0:42 when he said nonsense haha

  • @Cheezou.
    @Cheezou. 3 года назад +1

    Where is the code , i wanna compare with mine pls

  • @support_gaza
    @support_gaza Год назад +1

    How to delete one number?

  • @Knowmemelife
    @Knowmemelife Год назад

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

  • @Partha-q8h
    @Partha-q8h 8 месяцев назад

    Thanks

  • @sianbunny7724
    @sianbunny7724 8 месяцев назад

    thnx man
    🙏

  • @reskretny20
    @reskretny20 11 месяцев назад

    he looks like Nacho from Better call Saul

  • @diegos2184
    @diegos2184 2 месяца назад

    where did u learn to code?