Calculator Addition Function - Python Kivy GUI Tutorial #16

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024

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

  • @Codemycom
    @Codemycom  4 года назад +1

    ▶️ Watch Entire Kivy Playlist ✅ Subscribe To My RUclips Channel:
    bit.ly/37LrJ27 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
    ▶️ Get The Code
    bit.ly/37jtHoo

  • @SammarpanDasguptaOfficial
    @SammarpanDasguptaOfficial 4 года назад +1

    Thanks for that... Actually I was able to complete that project before that video.... But I just completed it only for your nice teaching... Thank you sir.....

  • @bradydeboer4694
    @bradydeboer4694 3 года назад +5

    I enjoyed this video and it was useful, but you could have just had passed the "+", "-", "*", and "\" operators into the button press function. Also you could have used self.ids.calc_input.text += f'{button}' instead of self.ids.calc_input.text = f'{prior}{button}. Edit: Also use eval.

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

    As Always Awesome Person and Awesome Teaching Congratulations Please Keep it up

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

    Thank you so much, Man! You are The Best Teacher!😊 Great KivyMD Python tutorial for all!

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

      Glad you enjoyed it!

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

    I kept screaming noooooo use the eval()...😂😂 Thanks for the effort

  • @hg_ofthecity_old_thi
    @hg_ofthecity_old_thi 4 года назад +2

    Thank you, Best teacher ever! haha, My all-time favorite part 0:00 0:20 0:34 , At that moment I be like :)

  • @ideasinprogress607
    @ideasinprogress607 4 года назад +1

    No special Cyber Monday code? I saw your deal last year, and have been waiting for a couple of months to see if there would be one this year. I know that what you are offering is worth much more, especially with your regular RUclips discount code, but you can't blame a guy for being a cheapsk.... er... thrifty. :) I really admire your business plan/implementation. Thanks for sharing your knowledge.

    • @Codemycom
      @Codemycom  4 года назад

      Ha, no cyber monday sale this year...

  • @CesarVerdes
    @CesarVerdes 2 года назад +2

    Perhaps this idea could simplify the code:
    formula = "1+2/3"
    print(f'{eval(formula)}')

  • @adityakomawar7210
    @adityakomawar7210 4 года назад +2

    Suppose you want to build a serious gui application say pdf viewer or any other application and you know tkinter, kivy, pyqt, qt, wxwidgets and electron. What would you use?Also which is your all round favourite gui framework/library ?

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

      It depends entirely on the app and what it needs to do. I don't have a favorite. These are just tools, you use the tool that the job best needs...

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

    Best lector !

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

    Thanks for this video series. I love it. But I have an easier solution. There is a python built-in function for this. The eval() function. It supports every basic math calculations included "(" , ")" and it can also deal with more than 2 numbers in the same time. Anyway... thanks for your videos, helped a lot.

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

      1+2*3 = 7, but when using calculator, 1+2*3 = (1+2)*3 = 9. I don't think it's a good idea to use eval().

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

      @@teyao eval('1+2*3') returns 7 thats correct

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

      ​@@tibssy1982 You are right about eval(), However, find a normal calculator and press '1', '+', '2', '*', '3', that will be 9.

    • @johannes-euquerofalaralema4374
      @johannes-euquerofalaralema4374 2 года назад +2

      I usually pause the video at the beginning and try to come up with the solution, then I watch it.
      I used this function:
      def equals(self):
      self.ids.calc_input.text = str(eval(self.ids.calc_input.text))
      I have no "old school calculator" at home, so I cannot check teyao's answer, but I guess he's right. However, Google's calculator seems to use "eval" too.

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

      @@johannes-euquerofalaralema4374 Great Job bro. You have made the function so easy, and it's looks so clean 😀😀😀

  • @MagicByIzzy
    @MagicByIzzy 4 года назад +1

    Thanks for the tutorials they're great!
    Can't you just say in your if statement name = f'{button}' instead of self.ids.calc_input.text

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

    In the kv file we placed a number inside the parentheses for each number button for the on press function, but as soon as I click python throws an error and the application quits despite copying your code exactly. So why this does not work?

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

    HELP please...how would one define a boolean function in the py file and call it as root.funcname when the '=' button is pressed? I tried def __init__(self): and then store the bool value of the variable but this results in segmentation error. what's the correct way to define it? thanks in advance. I am new to kivy but going thru every kivy video that you have posted on YoutTube. Great tutorials! Much thanks.

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

      Problem solved. Calculator app now working well as I like. After validating the result following press of '=' button, I don't need to press 'clear' to erase the result in the text input box to enter a new formula. Now, I just click any number and it goes in the input box.

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

    Hi, how could i change the output color, i tried putting color: 1, 1, 1, 1 under TextInput: in the kv file but it doesnt change anything....

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

    0 dislikes fantastic!

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

    When I press '=', it doesn't calculate anything, the calculator stays the same, waiting for other actions... I begin to press other buttons and press '=' again, and it gives me the mistake "ValueError: invalid literal for int() with base 10: '5-9*5'" ... Why?

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

      Maybe I do not have some necessary math libraries needed in this project?..

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

      @@lusienda There are no math libraries needed, you have a typo in your code somewhere. Check it against the code in the video.

  • @MajesticRiderTales
    @MajesticRiderTales 4 года назад +1

    👍

  • @0429akming
    @0429akming 2 года назад

    Why not using Eval()?

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

      If memory serves, we do that in a future video

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

    Plz tell how to download your code? Instead of copying it...

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

    exec(_kvlang_.co_value, idmap)
    File "c:\Users\hamza\Desktop\learn
    ame.kv", line 5, in on_press: root.button_press(1)
    File "kivy\\weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy._getattr_AttributeError: 'BoxLayout' object has no attribute 'button press'
    Plz help me

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

    0 dislikes fantastic!