Continue Building A Simple Calculator App - Python Tkinter GUI Tutorial #6

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

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

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

    ▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My RUclips 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

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

      What does END do

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

      @@donaldppaul3260 What do you think? It ends a thing.

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

      @@Codemycom pls explain why do you use a END in e.insert(END,number)

    • @100jsj6
      @100jsj6 3 года назад +1

      @@donaldppaul3260 coz he wanted to GET or DELETE from 0 (0 is first value in python if u dont know , so counting in py is 0,1,2,3 etc ) to the END of the string

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

      @@Codemycom I keep on getting a error "NameError: name 'f_num' is not defined" this is part of my script can someone help me fix it
      def button_add():
      first_number = e.get()
      global f_num
      f_num = int(first_number)
      e.delete(0, END)
      def button_equal():
      second_number = e.get()
      e.delete(0, END)
      e.insert(0, f_num + int(second_number))

  • @josephsevita5863
    @josephsevita5863 4 года назад +29

    You're genuine. This is how we code, making mistakes, hoping it runs, too many edited videos making the programmer look perfect, no syntax errors, never a question on how an API works. This should inspire aspiring programmers. Thanks.

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

      Thanks! Glad you like it!

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

    Hello from Brazil. I decided to learn some python, and I realized that the best way to learn something is use this something in a project. So I opened 10 youtube videos on "how to make a simple calculator with python", and after watching one of you videos I closed all the others. The way you explain things is very interesting, thanks for the amazing tutorials.

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

      Glad you enjoyed it!

  • @ничегосебе-в1ъ
    @ничегосебе-в1ъ 4 года назад +68

    1:10 On the 13th line you could write 'END' insead of 0 and it'll be working.

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

      nichego sebe

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

      Yes, I was about to say the same thing. Much simpler way.

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

      try with a capital letters,i tried and its work

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

      Yes, I'm agree with you!

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

      Genius. Just Genius

  • @Gvk795
    @Gvk795 5 лет назад +32

    "I'm just making this up as I go, you can tell." Made me laugh. Thank you for the video series this is very helpful and fun!

    • @Codemycom
      @Codemycom  5 лет назад +8

      ha, glad you're enjoying it!

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

    This is the best library introduction series of all time, seriously. The way you present and show things allows us to not only understand it, but to be able to create and implement into our own ideas immediately. Cannot thank you enough for your videos.

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

      Wow thanks! That's high praise! Glad you're enjoying them...

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

    We can also create a variable i and pass it in e.insert(i,number) and increment it each time for correct representation
    Then while clearing reset the value of i to 0
    This worked pretty well

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

    The best tkinter Tutorial in the youtube.

  • @mrunixman1579
    @mrunixman1579 9 месяцев назад +1

    Great video, this came in handy for my college project which requires python and Tkinter. Even my college tutor makes many mistakes in his program.

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

      Happy to hear it!

  • @اماديرأمان-ر9ك
    @اماديرأمان-ر9ك 2 года назад

    To how want's to learn python easy this good chanel لكل من يريد تعلم بايتون هذه القناة افضلل مكان للتعلم.
    شكرا كثيرا thanks lot

  • @EpicBURN321
    @EpicBURN321 5 лет назад +10

    A really simple way of fixing the calculator number input issue is to change "e.insert(0, number)" to "e.insert(END, number)". This eliminates the need for a "current" variable and the string concatenation

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

    Dude you are bloody brilliant. I will buy yours courses. Loving this!

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

      Awesome, glad you like it!

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

    I can't believe that I have 170 more amazing videos to watch!

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

    This channel is so underrated.

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

      Thanks! Tell your friends!

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

    Would be interesting which other ideas you guys came up with for doing the math. Maybe we can collect them in this thread.
    I used a little different approach and used result = eval(e.get()) for the equal button. The advantage is, that we can see the calculation all the time. Furthermore we can type in a calculation into the text field (which is of course not the aim of this video).

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

      I have used the following technique for adding number in right sequence.
      def button_click(number):
      e.insert(len(e.get())+1, number)
      it's simply adding the value at the end of currently available value.

  • @user-hl6cq4jm3l
    @user-hl6cq4jm3l 4 года назад +1

    U are the best programmer. that I saw

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

    So I did something like this:
    # for the equal button:
    def calculate_and_print():
    try:
    answer = eval(enter.get())
    button_clear()
    button_click(answer)
    except(SyntaxError):
    enter.insert(0, "")
    And I just passed the button_click function a "+". It worked! In a different way though
    😆

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

    I like your reaction when your code runs! lol

  • @SidneyJohnson-q7h
    @SidneyJohnson-q7h 28 дней назад +1

    Couldn´t you just save the input of everything, when they hit '=' the program splits the string in plus and then you just sum() the list. Or would´t it work?

  • @數學只考6級分
    @數學只考6級分 5 лет назад +12

    Why we should use lambda to execute the command

    • @Codemycom
      @Codemycom  5 лет назад +14

      Because that's the only way tkinter allows you to pass variables through your function from the button.

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

      @@Codemycom It's not the only way, just a very common way. For example, you could also use functools.partial.

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

    Best web series I am watching right now

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

    Gracias profe, saludos desde Bucaramanga-Colombia

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

    For the add and equal buttons you can use something like that :
    This way you can add multiples numbers not just two
    (I am using class so just remove "self")
    self.sm = 0 # sum
    def btn_add(self):
    self.sm += int(self.e.get())
    self.e.delete(0,END)
    def btn_eq(self):
    add = int(self.e.get())
    self.e.delete(0,END)
    self.e.insert(0,self.sm+add)
    self.sm=0

  • @andrejvujic
    @andrejvujic 4 года назад +4

    You could've used the inbuilt string split method for adding numbers, btw thanks for the great tutorial series

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

      Sure, there's always a hundred different ways you can do a thing

  • @aliabedi-hp8ls
    @aliabedi-hp8ls Год назад

    thanks for your video. so informative and efficient. every day i go on with more motivation and strong will. i hope we become expert developers in end and be professional. and i hope to not be taken back or demotivated of this,

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

    one ez way is to
    insert the input number Not on the zeroth position, but at the end of the total length of the hall number elements in the entry by adding +1 like ..
    def put_num(num):
    entry_elements=win.get()
    total_len=len(entry_elements)
    win.insert(total_len+1,str(num))

  • @mbn-code
    @mbn-code 4 года назад +2

    now playing around with the fx: def button_clear(): thing i thought of making an exit button even tho i kno you can just press in the top corner but, if anyone want a exit button
    i am very new to coding and python, so this is properbly ugly to some body, but hey this is just about learning and having fun wwith it
    line 1:
    def function(exit):
    pass
    def button_exit():
    button_exit = function(exit())
    line 2:
    button_exit = Button(root, text="exit", padx=40, pady=20, command=button_exit)
    line 3:
    button_exit.grid(row=6, column=1, columnspan=1)

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

    For some reason the exact same code didn't work using PyCharm but worked on VS code, I'm not sure why but otherwise great tutorial I'm loving this so far

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

      Because pyCharm is garbage.

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

    Hi, the videos are all good, thank you very much.

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

    We may write
    a=e.get()
    e.insert(len(a),num)

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

    2:47
    if you type
    click the buttons like this
    1,2,3,4,5,6...
    you get the abacaba sequence!

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

    VERY HELPFUL, IM JUST A 13-YEAR-OLD AND I LOVE IT, THANKS A LOT, @PRANAVA
    AND DO YOU HAVE 1 TO 1 COURSES

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

      Glad you liked it. I don't know what 1 to 1 courses are.

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

      @@Codemycom one instructor , one student. Mo' Moneyy!

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

      @@varadvithalkj1716 Not true at all lol one instructor, one student = MASSIVELY LESS money. Lol I'd rather do it the way I do now...one instructor makes a video and 100,000 students watch it lol THAT'S more money lol would you rather have 1 student paying you, or 100,000 students paying you?

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

      @@Codemycom i didnt really understand the money part, sorry i thought thats how it worked, but anyways thanks for this amazing seeries tho

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

    for button_click instead of deleting the entire entry, and then re-adding it, I just changed the insert position to be len(e.get()), which inputs the button entry after the last character of the textbox. My whole button_click function reads:
    def button_click(number):
    e.insert(len(e.get()), number)

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

    My first thought for doing the addition was to just turn this into a class :P

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

    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.

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

      Tako da ih označiš kao intiger ili float, a ne kao string zato što ako ga program vidi kao string to je isto kao da vidi neku riječ, oprosti ako govorim ovo a već si naučio.
      intiger(int) je neki cijeli broj
      float je neki broj koji ima decimalu

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

      Već sam dovršio projekt no svejedno - puno hvala !
      Lijepo je kada znaš da je netko zapravo odvojio svoje vrijeme kako bi ti pomogao / odgovorio. 😃

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

    So helpful! Thank you!

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

      Glad you liked it Angelaine!

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

    Use: e.insert(END, str(number)) to append text in one command

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

    This is simpliest code for button_click and button_delete:
    def button_click(number):
    display.insert(END, number)
    def button_delete():
    last = len(display.get())
    display.delete(last - 1, END)

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

      There are always infinite ways to do a thing.

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

    2:30 Just write "e.insert(END, number)"

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

    i tried it on my own and i think that the addition algo works for only 2 nos in continuity. like if we do 2+2 it gives 4. but when we do 2+2+2 it still gives 4 because we have used only first and second number... is there any solution to it???

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

      store result in a list and when u hit equal to then only process sum of all the element in the list

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

      @@sarvdeepsangwan1207 okh thank u 👍

  • @luciferkhusrao
    @luciferkhusrao 4 года назад +6

    Sir, if we use this e.insert(END,number), then we can do it in just 1 line

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

    thank you for this. helps a lot!

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

    insert all values as string and use eval function. it will be better

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

    Hey there, thanks for this fantastic video series!
    I'm confused on the logic of this, I'm not understanding how do the numbers print out and not append everytime:
    def button_click(num):
    current = e.get()
    e.delete(0, END)
    e.insert(0, str(current) + str(num))
    Can you please help me on this?

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

      Not sure what you mean

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

      @@Codemycom sorry I figured it out now! Had to go through your tutorial 3 times to understand, because I'm a complete noob! :(
      But I'm getting better now, thanks to your tutorials 😎

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

      @@Abhijeetetrx ah cool, glad you got it sorted out :-)

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

      def button_click(num):
      e.insert(len(e.get()), num)
      i found out this will be more easier and it work out the same
      hope it help you out

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

    instead of e.delete and all of those other stuff u could have just done e.insert(END, number), it worked well for me i dont know if it is the correct way cause i havent completed my calc yet.

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

      That just slaps it on the end of the entry box. If there's another number there already it wont work

  • @Cherry-z4f
    @Cherry-z4f 9 месяцев назад

    Hello , you're amazing , I'm sorry i have a problem , the global variable it doesn't work for me , what's the problem?

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

      You used it incorrectly. What did you do differently from the video?

  • @johnpro2847
    @johnpro2847 5 лет назад +2

    Thanks ..helpful

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

    hey i was just wondering is there any way to have a backspace button, which only deletes the last digit??

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

      Sure would just take a little tinkering. You can get the last character of a string with [-1] or you can return everything in a string except the last character with [:-1]....so if your string is named my_string, you can return everything but the last character by calling my_string[:-1]
      Just set that up in a function that gets called when you click the button...and config it to the entry box or whatever

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

      You may write func like this
      a=e.get()
      e.delete(len(a)-1,END)

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

    If I wanna write the number 123, to fix the adding problem, I used:
    def buuton_click(number):
    e.insert(END, number)

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

    thank you!
    can you know how can i create a calculator salary avarage with this?

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

    Instead of getting the current value, deleting it, and then inserting it back with the concatenation, you can just use e.insert(END, number).

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

    you can out the two numbers in a list and add them together

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

    Need a Recommendation! : We should learn Kivy or Tkinter?

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

      How can I possibly answer that? I have no idea what you need to do, what you want to use it for, the sort of apps you want to build, or your experience, skill, or aptitude.

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

      @@Codemycom Just want to build ToDoList

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

      @@khizaridrees1758 I'm building a todo list in tkinter right now...check the playlist.

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

    Great content John! I really appreciate your videos!
    Does anyone know how to do unit test on GUI? like in this case, how can you make a unit test to verify that the function "def button_add():" works correctly?

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

    Hello,
    I have run into an issue when it comes to displaying multiple numbers on the display.
    When I use the .get() function I either receive an error (listed below) or when I implemented a solution I thought would work [.get(0.0, tk.END)], I simply received nothing on my text box nor did I receive any errors.
    The previous tests you showed on the video (numbers being typed in the wrong order etc.) worked fine on my program.
    Assistance of any kind would be greatly appreciated.
    Thank you.
    ---------------------------------------------------------
    CODE
    def ButtonClick(number):
    current = InputBox.get()
    InputBox.delete(0.0, tk.END)
    InputBox.insert(0.0, str(current) + str(number))
    ----------------------------------------------------------
    ERROR
    current = InputBox.get()
    TypeError: get() missing 1 required positional argument: 'index1'

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

      Seems like there's an error with your get() code...did you really name it InputBox?

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

      @@Codemycom I figured as such but am unsure of what must be done to fix the error related to the .get() code.
      In terms of the InputBox, I named it that as I was planning to have another text box above it to show the equation the user inputted (EquationBox), once receiving the answer in the InputBox.
      Would this negatively affect my program or the process of creating it?
      Thank you for responding, it helps a great deal hearing from a professional.

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

    Error is showing in line
    f_num = int(first_number)
    What i wrote
    def button_add():
    first_number=e.get()
    f_num=int(first_number)
    e.delete(0,END)
    What can be my mistake, please tell

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

      what is the error telling you?

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

      I am using Python version 3.9.0
      and the error is
      Invalid Literal for int() with base 10

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

      did you use the letter 0 instead of the number 0 in your calculator label?

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

      I used letter 0

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

      @@ansh4786 It must be number 0...this is a calculator...it does math to numbers. integers.

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

    I NEED HELP!
    at the very last part of the video where we define the button_equal i keep on this error:
    line 30, in button_equal
    e.insert(0, f_num + int(second_number))
    TypeError: int() argument must be a string, a bytes-like object or a number, not 'method'

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

      Here, i even copied and pasted all the code on my screen so far..
      from tkinter import *
      root = Tk()
      root.title("Yahya's Addition Calculator")
      e = Entry(root, width=35, borderwidth=5)
      e.grid(row=0, column=0, columnspan=3, padx=10, pady=10)
      def button_click(number):
      # e.delete(0, END)
      current = e.get()
      e.delete(0, END)
      e.insert(0, str(current) + str(number))

      def button_clear():
      e.delete(0, END)
      def button_add():
      first_number = e.get()
      global f_num
      f_num = int(first_number)
      e.delete(0, END)
      def button_equal():
      second_number = e.get
      e.delete(0, END)
      e.insert(0, f_num + int(second_number))
      button_1 = Button(root, text="1", padx=40, pady=20, command=lambda: button_click(1))
      button_2 = Button(root, text="2", padx=40, pady=20, command=lambda: button_click(2))
      button_3 = Button(root, text="3", padx=40, pady=20, command=lambda: button_click(3))
      button_4 = Button(root, text="4", padx=40, pady=20, command=lambda: button_click(4))
      button_5 = Button(root, text="5", padx=40, pady=20, command=lambda: button_click(5))
      button_6 = Button(root, text="6", padx=40, pady=20, command=lambda: button_click(6))
      button_7 = Button(root, text="7", padx=40, pady=20, command=lambda: button_click(7))
      button_8 = Button(root, text="8", padx=40, pady=20, command=lambda: button_click(8))
      button_9 = Button(root, text="9", padx=40, pady=20, command=lambda: button_click(9))
      button_0 = Button(root, text="0", padx=40, pady=20, command=lambda: button_click(0))
      button_add = Button(root, text="+", padx=39, pady=20, command= button_add)
      button_equal = Button(root, text="=", padx=91, pady=20, command= button_equal)
      button_clear = Button(root, text="Clear", padx=79, pady=20, command=button_clear)
      #place button on screen
      button_1.grid(row=3, column=0)
      button_2.grid(row=3, column=1)
      button_3.grid(row=3 , column=2)
      button_4.grid(row=2, column=0)
      button_5.grid(row=2, column=1)
      button_6.grid(row=2, column=2)
      button_7.grid(row=1, column=0)
      button_8.grid(row=1, column=1)
      button_9.grid(row=1, column=2)
      button_0.grid(row=4, column=0)
      button_clear.grid(row=4, column=1, columnspan=2)
      button_equal.grid(row=5, column=1, columnspan=2)
      button_add.grid(row=5, column=0 )
      root.mainloop()

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

      @@shamailanaimat7347 the error is in your button_equal function definition,
      wrong: second_number = e.get
      correct: second_number = e.get()
      The problem is that you assigned e.get to second_number, thus making second_number a function equivalent to e.get.
      whereas you should have assigned e.get() to second_number. which assigns the return value of the e.get() function to your second_number variable.

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

    Thank you

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

    Can't I just use e.insert(END, number) or is there a problem?

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

    in line 29 e.insert(0, f_num + int(second_number))
    f_num is not definited
    why
    i did it

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

      please heeelp me

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

      rewatch the entire video, you likely missed something

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

      @@Codemycom I did, but I didn't find a mistake.

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

    pretty coooooool

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

    I have a question, why all the numerical buttons used lambda function whereas others don't? When do I have to use lambda and when not?

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

      because when you want to pass something to a function, you must use lambdas. The clear button doesn't pass anything to a function, so we don't have to use lambda.

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

      @@Codemycom OK,really thanks and I pray for the US, keep strong💪💪

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

      @@lzh00 Sure thing

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

      @@Codemycom Can you help me show plots using a GUI? I use Seaborn and Matplotlib to show plots based on data, how can I have a button that when clicked shows a plot?

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

      @@lzh00 already did: ruclips.net/video/8exB6Ly3nx0/видео.html

  • @johankotze42
    @johankotze42 5 лет назад +2

    In button_click I did:
    e.insert( len( e.get() ) , digit )
    to address that incorrect order.

    • @彭随风
      @彭随风 5 лет назад +1

      e.insert( END , digit )

    • @彭随风
      @彭随风 5 лет назад +2

      e.insert( END , digit )

    • @johankotze42
      @johankotze42 5 лет назад

      @@彭随风 Yes. Much better! :-)

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

    your simple but complicated. This is my first experience with python, the parts you assumed we know are the ones Im struggling with. I cant download or find Ming64 and took a while to understand where Kinter was or how to open it.

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

      also using linux commands on a windows os confuses new guys even more, cause theyll try them on powershell

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

      ming64 isn't a thing. You want the git bash terminal. git-scm.com or any terminal. Tkinter comes with Python, there's nothing to find or open.

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

      @@Codemycom Took a while for me to notice that since I know nothing about Python. As for using other terminals I tried powershell, not sure if its my command or code thats not correct

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

      @@DestoFlix No there is no powershell on linux. Just use the linux terminal. It comes with linux.

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

      @@Codemycom perhaps something got lost in translation anyway the github app you recommended I download is working great and we are on the same page now. Much appreciated John

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

    5:00 why did he remove the brackets from in front of the function, don't we need them to call a function ?

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

      Because the clear button calls a function that doesn't require a parameter. Therefore no lambda and no brackets are needed :)

    • @ничегосебе-в1ъ
      @ничегосебе-в1ъ 3 года назад +1

      it calls a void

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

    great, thanks

  • @rushey_1771
    @rushey_1771 5 лет назад +1

    Thanks bro🤗

    • @Codemycom
      @Codemycom  5 лет назад

      sure thing

    • @rushey_1771
      @rushey_1771 5 лет назад

      @@Codemycom bro one help: How to provide entry box for only getting integer input??

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

    Cool and helpful videos! But why didn't you just use this?:
    def button_add():
    current = e.get()
    e.delete(0, END)
    e.insert(0, str(current) + "+")

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

      Always a million ways to do a thing

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

    obrigado pelos videos

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

    Created program using same code as your . But I’m not getting the value of the button pressed .in the entry field . Using lambda under command .

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

      Then you have a typo somewhere. Is lambda lowercase?

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

    how do I get the program to close by itself? I mean the X button is pretty clear, but shouldn't import sys and then sys.exit() work? because I have tried and it doesn't really do anything.

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

      root.quit() usually works. root.destroy() might do the trick

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

    How do you do a while loop with the tkinter library

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

      In the same way you do any while loop...it's python, it has nothing to do with tkinter.

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

    Thanks for the tutorial.
    I have a query. If I add 2 numbers e.g. 4+5 answer comes as 9 and if I don't click clear button. the next number I click will display next to 9. like 932. What should I do?

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

      continue watching the videos

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

    its telling me the colon after lambda for line 29 for you is a invalid syntax

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

      Did you use a capital L in lambda? It needs to be lowercase

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

    dose this works in pychram

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

      Exception in Tkinter callback
      Traceback (most recent call last):
      File "C:\Users\Dell\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
      return self.func(*args)
      File "C:/Users/Dell/PycharmProjects/Tk.py", line 20, in button_add
      f_num=int(first_number)
      ValueError: invalid literal for int() with base 10: ''

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

      no idea...I would never use pycharm

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

    Why did we use lambda in the first place?

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

    I remember when I did this programming, I couldn't multiply and that was because I incorrectly spelt 'multiplication' somewhere

  • @levinaa.377
    @levinaa.377 2 года назад

    what does e.get and e.grid mean?

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

      Go back to the beginning of this playlist and start watching the videos if you want to learn those incredibly basic things.

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

    Watch at x1.25. Enjoy!

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

      lol

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

      @@Codemycom Haha. You are brilliant. I was looking your videos right now !:)

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

      @@imherovirat thanks

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

    Sir while executing the stuff the system said that 'padx' is not defined. How should I fix that?

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

      check your code for typos. It has to be exact

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

    Using VS Code for tutorial. pylint keeps saying 'button_click is not callable.' I've looked online, but I haven't seen any solutions for how to fix this.
    What are your suggestions?

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

      Don't use vscode lol I use sublime text and git-scm.com for the terminal.

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

      Fixed it last night: it was an issue with how I accidentally factored one of the button names to be similar to a function used in program. That caused something with another function call to get stated as not callable.
      VS Code is fine; I just need to make sure I'm writing down everything as it appears in the video one-to-one.
      If this happens again with a video tutorial, I'll just make a github post with the finished script after each video for my own personal reference.

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

    what is the function of padx and pady? In the net it says "how many pixels to pad widget horizontally/vertically outside the widget's borders." I don't understand this statement. Could you please explain.

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

      they deal with spacing around the widget. x is space to the left and right y is space above and below

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

      @@Codemycom thank you 👍

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

      @@vik0_052 sure thing

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

    def button_click(number):
    e.insert(END, number)

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

    8:29 i got confused from the concept of how does the python calculator makes the + automaticly and what about more advanced programs im really deep into python i love how easy its to run a project :D not like javascript xD

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

    11:52

  • @AnujKumar-xn5tg
    @AnujKumar-xn5tg 4 года назад

    Sir I have also made an Calculator .But can we send this app to others via link or an url??

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

      Sure...you need to convert it into an exe file first...which can be tricky.

    • @AnujKumar-xn5tg
      @AnujKumar-xn5tg 4 года назад

      @@Codemycom I will try

    • @AnujKumar-xn5tg
      @AnujKumar-xn5tg 4 года назад

      @@Codemycom sir i have convert it into exe file
      now what is the next step ...

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

      @@AnujKumar-xn5tg You need to upload it to a website where you can give the link out

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

    WHAT DOES END DO PLS HELP

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

      End ends a thing

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

      @@Codemycom pls explain e.delete(0,END) WHAT DOES THAT END

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

      @@donaldppaul3260 Oh, that's the end of the box. Each character in the entry box is numbered, and you want to delete everything in the box from the first character to the end character.

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

      @@Codemycom thank you for helping .that was a pain. I thought you would be harsh but you are a nice guy

  • @رادیندولتی
    @رادیندولتی 3 года назад

    great

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

    def button_clear():
    e.delete(0, END)
    Dear Sir, I'm facing problem on these lines.

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

      Hmmm try e.insert(0, END)

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

    it says f_num not defined. Why?
    nvm found my mistake

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

    Hello, I followed the code but when I tried to run, this appeared: " line 21, in button_addition
    f_num = int(first_number)
    ValueError: invalid literal for int() with base 10: '' "
    whereas my code is:
    def button_addition():
    first_number = e.get()
    global f_num
    f_num = int(first_number)
    e.delete(0, END)
    I don't understand why.. Please help

    • @user-zq1vg8xm1p
      @user-zq1vg8xm1p 3 года назад +3

      Look at @cookie 's comment.
      if it doesn't solve the problem, I recommend removing the bracket from the command=button_addition(),
      for example,
      butadd = Button(root, text="+", padx=39, pady=20, command=button_addition())
      needs to be :
      butadd = Button(root, text="+", padx=39, pady=20, command=button_addition)
      if that doesn't work, put the 'eval' function before the variable in the int
      for example :
      def button_addition():
      first_number = e.get()
      global f_num
      f_num = int(first_number)
      e.delete(0, END)
      needs to be :
      def button_addition():
      first_number = e.get()
      global f_num
      f_num = int(eval(first_number))
      e.delete(0, END)
      hope this helps :D

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

      @@user-zq1vg8xm1p man you are briliant

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

    invalid literal for int() with base 10: ''....... I'm getting this error. How can I fix this??

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

      You likely have a typo

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

      @@Codemycom I'm having another error. I'm getting invalid syntax for
      def button_clear():
      e.delete(0, END)

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

      @@rakeshkundu e.delete(0, END) that should be a zero not the letter O, right? If that's not the issue, try "end" instead of END

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

    where can i get your code?

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

      github.com/flatplanet/Intro-To-TKinter-RUclips-Course

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

    'Lambda: ' doesn't work. Can I install that?

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

      Yes it does work, you used a capital L instead of lowercase.

  • @m.hassanakram6527
    @m.hassanakram6527 4 года назад

    What do it's saying f_num is not defined in the global scope?

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

      try making it global

    • @m.hassanakram6527
      @m.hassanakram6527 4 года назад

      @@Codemycom before the function I wrote f_num = 0 then it worked,what does this mean?

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

      @@m.hassanakram6527 you have to assign something to a variable before you call the variable...

    • @m.hassanakram6527
      @m.hassanakram6527 4 года назад

      @@Codemycom thanku but how ur code worked without it😂

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

      @@m.hassanakram6527 Then why didn't yours? You must have done something differently

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

    The "END" word gives me error. What should i do?

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

      Try and write it in small letters. Sorry for late reply

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

    I have a syntax error when putting lambda,button_1=Button(root,text="9",padx=40,pady=30,command=Lambda: button_click(9))
    Can u help me

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

      The L in lambda needs to be lower case, not capitalized

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

      @@Codemycom Thank u

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

      @@faheemali5160 sure thing

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

    Kivy vs Tkinter ? with Reason.😊

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

      Every tool is different, has different strengths and weaknesses depending on what you need to use it for.

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

      @@Codemycom Thank you so much.❤

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

    my microsoft VS says i got 200 problems...
    how?

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

      Who knows. I would never use that tool.

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

    Error f_num is not define in the global scope python

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

      make f_num global then