▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZbin 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
@donaldppaul32603 жыл бұрын
What does END do
@Codemycom3 жыл бұрын
@@donaldppaul3260 What do you think? It ends a thing.
@donaldppaul32603 жыл бұрын
@@Codemycom pls explain why do you use a END in e.insert(END,number)
@100jsj63 жыл бұрын
@@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
@Tinker2502 жыл бұрын
@@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))
@josephsevita58634 жыл бұрын
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.
@Codemycom4 жыл бұрын
Thanks! Glad you like it!
@ничегосебе-в1ъ4 жыл бұрын
1:10 On the 13th line you could write 'END' insead of 0 and it'll be working.
@dinona2474 жыл бұрын
nichego sebe
@kjn59914 жыл бұрын
Yes, I was about to say the same thing. Much simpler way.
@noaharonoff4 жыл бұрын
try with a capital letters,i tried and its work
@ozbekchawindows42364 жыл бұрын
Yes, I'm agree with you!
@NOAHBENJ4 жыл бұрын
Genius. Just Genius
@helio65402 жыл бұрын
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.
@Codemycom2 жыл бұрын
Glad you enjoyed it!
@markblair16554 жыл бұрын
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.
@Codemycom4 жыл бұрын
Wow thanks! That's high praise! Glad you're enjoying them...
@Gvk7955 жыл бұрын
"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!
@Codemycom5 жыл бұрын
ha, glad you're enjoying it!
@aminmech Жыл бұрын
The best tkinter Tutorial in the youtube.
@Codemycom Жыл бұрын
Thanks!
@mrunixman157910 ай бұрын
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.
@Codemycom10 ай бұрын
Happy to hear it!
@kameenabandar37723 жыл бұрын
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
@اماديرأمان-ر9ك2 жыл бұрын
To how want's to learn python easy this good chanel لكل من يريد تعلم بايتون هذه القناة افضلل مكان للتعلم. شكرا كثيرا thanks lot
@Codemycom2 жыл бұрын
Thanks!
@mrawesome77393 жыл бұрын
I can't believe that I have 170 more amazing videos to watch!
@Codemycom3 жыл бұрын
Enjoy!
@daveandpamwilkinson38835 жыл бұрын
Dude you are bloody brilliant. I will buy yours courses. Loving this!
@Codemycom5 жыл бұрын
Awesome, glad you like it!
@EpicBURN3215 жыл бұрын
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
@parfaitmombo9665 жыл бұрын
Thanks, it worked.
@hossamketfi98922 жыл бұрын
This channel is so underrated.
@Codemycom2 жыл бұрын
Thanks! Tell your friends!
@user-hl6cq4jm3l4 жыл бұрын
U are the best programmer. that I saw
@Codemycom4 жыл бұрын
Thanks!
@umpalumpa28834 жыл бұрын
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).
@SyedAlirazarizvi722 жыл бұрын
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.
@_Cartographer_4 жыл бұрын
5:00 why did he remove the brackets from in front of the function, don't we need them to call a function ?
@khareek24534 жыл бұрын
Because the clear button calls a function that doesn't require a parameter. Therefore no lambda and no brackets are needed :)
@ничегосебе-в1ъ3 жыл бұрын
it calls a void
@jorgebalagueraespinosa5936 Жыл бұрын
Gracias profe, saludos desde Bucaramanga-Colombia
@Codemycom Жыл бұрын
Welcome
@數學只考6級分5 жыл бұрын
Why we should use lambda to execute the command
@Codemycom5 жыл бұрын
Because that's the only way tkinter allows you to pass variables through your function from the button.
@bryanoakley51894 жыл бұрын
@@Codemycom It's not the only way, just a very common way. For example, you could also use functools.partial.
@SidneyJohnson-q7hАй бұрын
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?
@AhrenBaderJarvis4 жыл бұрын
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)
@Codemycom4 жыл бұрын
cool
@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,
@Codemycom Жыл бұрын
Welcome!
@pragunashok60084 жыл бұрын
hey i was just wondering is there any way to have a backspace button, which only deletes the last digit??
@Codemycom4 жыл бұрын
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
@hardikpunj93214 жыл бұрын
You may write func like this a=e.get() e.delete(len(a)-1,END)
@kidredglow2060 Жыл бұрын
2:47 if you type click the buttons like this 1,2,3,4,5,6... you get the abacaba sequence!
@luciferkhusrao4 жыл бұрын
Sir, if we use this e.insert(END,number), then we can do it in just 1 line
@Codemycom4 жыл бұрын
yeah
@sasitobs4884 Жыл бұрын
Best web series I am watching right now
@Codemycom Жыл бұрын
Happy to hear it!
@marcmathieutrance68072 жыл бұрын
I like your reaction when your code runs! lol
@utsavpunia4204 жыл бұрын
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???
@sarvdeepsangwan12073 жыл бұрын
store result in a list and when u hit equal to then only process sum of all the element in the list
@utsavpunia4202 жыл бұрын
@@sarvdeepsangwan1207 okh thank u 👍
@andrejvujic4 жыл бұрын
You could've used the inbuilt string split method for adding numbers, btw thanks for the great tutorial series
@Codemycom4 жыл бұрын
Sure, there's always a hundred different ways you can do a thing
@shamailanaimat73474 жыл бұрын
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 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.
@Abhijeetetrx4 жыл бұрын
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?
@Codemycom4 жыл бұрын
Not sure what you mean
@Abhijeetetrx4 жыл бұрын
@@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 😎
@Codemycom4 жыл бұрын
@@Abhijeetetrx ah cool, glad you got it sorted out :-)
@kaihinliew29764 жыл бұрын
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
@IceTheCoder Жыл бұрын
Can't I just use e.insert(END, number) or is there a problem?
@lzh004 жыл бұрын
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?
@Codemycom4 жыл бұрын
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.
@lzh004 жыл бұрын
@@Codemycom OK,really thanks and I pray for the US, keep strong💪💪
@Codemycom4 жыл бұрын
@@lzh00 Sure thing
@lzh004 жыл бұрын
@@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?
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 😆
@fixitalltech10144 жыл бұрын
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 .
@Codemycom4 жыл бұрын
Then you have a typo somewhere. Is lambda lowercase?
@brodie21174 жыл бұрын
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'
@Codemycom4 жыл бұрын
Seems like there's an error with your get() code...did you really name it InputBox?
@brodie21174 жыл бұрын
@@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.
@jelayneds24225 жыл бұрын
So helpful! Thank you!
@Codemycom5 жыл бұрын
Glad you liked it Angelaine!
@hectorramsey3186 ай бұрын
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
@Codemycom6 ай бұрын
Because pyCharm is garbage.
@manikandannatarajan96654 жыл бұрын
VERY HELPFUL, IM JUST A 13-YEAR-OLD AND I LOVE IT, THANKS A LOT, @PRANAVA AND DO YOU HAVE 1 TO 1 COURSES
@Codemycom4 жыл бұрын
Glad you liked it. I don't know what 1 to 1 courses are.
@varadvithalkj17164 жыл бұрын
@@Codemycom one instructor , one student. Mo' Moneyy!
@Codemycom4 жыл бұрын
@@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?
@varadvithalkj17164 жыл бұрын
@@Codemycom i didnt really understand the money part, sorry i thought thats how it worked, but anyways thanks for this amazing seeries tho
@kindersmith84074 жыл бұрын
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.
@Codemycom4 жыл бұрын
root.quit() usually works. root.destroy() might do the trick
@johankotze425 жыл бұрын
In button_click I did: e.insert( len( e.get() ) , digit ) to address that incorrect order.
@彭随风5 жыл бұрын
e.insert( END , digit )
@彭随风5 жыл бұрын
e.insert( END , digit )
@johankotze425 жыл бұрын
@@彭随风 Yes. Much better! :-)
@vik0_0524 жыл бұрын
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.
@Codemycom4 жыл бұрын
they deal with spacing around the widget. x is space to the left and right y is space above and below
@vik0_0524 жыл бұрын
@@Codemycom thank you 👍
@Codemycom4 жыл бұрын
@@vik0_052 sure thing
@hardikpunj93214 жыл бұрын
We may write a=e.get() e.insert(len(a),num)
@Codemycom4 жыл бұрын
sure
@karlobucic44124 жыл бұрын
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.
@lukag05694 жыл бұрын
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
@karlobucic44124 жыл бұрын
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. 😃
@ahmedlimam22414 жыл бұрын
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
@Codemycom4 жыл бұрын
fun
@skfungaming13084 жыл бұрын
in line 29 e.insert(0, f_num + int(second_number)) f_num is not definited why i did it
@skfungaming13084 жыл бұрын
please heeelp me
@Codemycom4 жыл бұрын
rewatch the entire video, you likely missed something
@skfungaming13084 жыл бұрын
@@Codemycom I did, but I didn't find a mistake.
@REXanadu4 жыл бұрын
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?
@Codemycom4 жыл бұрын
Don't use vscode lol I use sublime text and git-scm.com for the terminal.
@REXanadu4 жыл бұрын
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.
@hagaibuachi21663 жыл бұрын
thank you! can you know how can i create a calculator salary avarage with this?
@Codemycom3 жыл бұрын
use basic math
@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))
@ritusree054 жыл бұрын
Sir while executing the stuff the system said that 'padx' is not defined. How should I fix that?
@Codemycom4 жыл бұрын
check your code for typos. It has to be exact
@rverm10003 жыл бұрын
How do you do a while loop with the tkinter library
@Codemycom3 жыл бұрын
In the same way you do any while loop...it's python, it has nothing to do with tkinter.
@GabrielFragadaSilva10 ай бұрын
2:30 Just write "e.insert(END, number)"
@thehash83 жыл бұрын
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?
@Codemycom3 жыл бұрын
continue watching the videos
@mbn-code4 жыл бұрын
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)
@lonxwolx2 жыл бұрын
thank you for this. helps a lot!
@Codemycom2 жыл бұрын
Glad to hear it!
@3d_holyshit_tech5913 жыл бұрын
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
@rodrigomsvlog4 жыл бұрын
If I wanna write the number 123, to fix the adding problem, I used: def buuton_click(number): e.insert(END, number)
@dylanl48022 жыл бұрын
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.
@Codemycom2 жыл бұрын
That just slaps it on the end of the entry box. If there's another number there already it wont work
@christophersantillan33933 жыл бұрын
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?
@raghavvasdeva29144 жыл бұрын
Can you explain why 15 become 151 & 1517 becomes 1517151 at 3:50sec of video
@Codemycom4 жыл бұрын
don't I explain it in the video a little further on?
@raghavvasdeva29144 жыл бұрын
I don't understand it. Kindly explain it again
@Codemycom4 жыл бұрын
@@raghavvasdeva2914 Sorry, rewatch the video.
@Cherry-z4f10 ай бұрын
Hello , you're amazing , I'm sorry i have a problem , the global variable it doesn't work for me , what's the problem?
@Codemycom10 ай бұрын
You used it incorrectly. What did you do differently from the video?
@_Cartographer_4 жыл бұрын
Why did we use lambda in the first place?
@Thememermanwhoisafan2 жыл бұрын
its telling me the colon after lambda for line 29 for you is a invalid syntax
@Codemycom2 жыл бұрын
Did you use a capital L in lambda? It needs to be lowercase
@porcelainface78094 жыл бұрын
My first thought for doing the addition was to just turn this into a class :P
@Codemycom4 жыл бұрын
fun
@khizaridrees17584 жыл бұрын
Need a Recommendation! : We should learn Kivy or Tkinter?
@Codemycom4 жыл бұрын
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.
@khizaridrees17584 жыл бұрын
@@Codemycom Just want to build ToDoList
@Codemycom4 жыл бұрын
@@khizaridrees1758 I'm building a todo list in tkinter right now...check the playlist.
@ansh47863 жыл бұрын
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
@Codemycom3 жыл бұрын
what is the error telling you?
@ansh47863 жыл бұрын
I am using Python version 3.9.0 and the error is Invalid Literal for int() with base 10
@Codemycom3 жыл бұрын
did you use the letter 0 instead of the number 0 in your calculator label?
@ansh47863 жыл бұрын
I used letter 0
@Codemycom3 жыл бұрын
@@ansh4786 It must be number 0...this is a calculator...it does math to numbers. integers.
@sugarcurls455011 күн бұрын
You're Epiccc!!!
@rakeshkundu3 жыл бұрын
invalid literal for int() with base 10: ''....... I'm getting this error. How can I fix this??
@Codemycom3 жыл бұрын
You likely have a typo
@rakeshkundu3 жыл бұрын
@@Codemycom I'm having another error. I'm getting invalid syntax for def button_clear(): e.delete(0, END)
@Codemycom3 жыл бұрын
@@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
@m.hassanakram65274 жыл бұрын
What do it's saying f_num is not defined in the global scope?
@Codemycom4 жыл бұрын
try making it global
@m.hassanakram65274 жыл бұрын
@@Codemycom before the function I wrote f_num = 0 then it worked,what does this mean?
@Codemycom4 жыл бұрын
@@m.hassanakram6527 you have to assign something to a variable before you call the variable...
@m.hassanakram65274 жыл бұрын
@@Codemycom thanku but how ur code worked without it😂
@Codemycom4 жыл бұрын
@@m.hassanakram6527 Then why didn't yours? You must have done something differently
@juztinnandricepillo98243 жыл бұрын
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-zq1vg8xm1p3 жыл бұрын
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
@mayurkalsekar5243 жыл бұрын
@@user-zq1vg8xm1p man you are briliant
@levinaa.3772 жыл бұрын
what does e.get and e.grid mean?
@Codemycom2 жыл бұрын
Go back to the beginning of this playlist and start watching the videos if you want to learn those incredibly basic things.
@faheemali51604 жыл бұрын
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
@Codemycom4 жыл бұрын
The L in lambda needs to be lower case, not capitalized
@faheemali51604 жыл бұрын
@@Codemycom Thank u
@Codemycom4 жыл бұрын
@@faheemali5160 sure thing
@leoronneland26334 жыл бұрын
hey john, how shold i do if i want the calculator to be able to calculate the sum of three numbers, for examole 1 + 1 +1, thank you for this course btw :)
@Codemycom4 жыл бұрын
You'll have to play around with it and try some things. Work it out!
@leoronneland26334 жыл бұрын
Codemy.com thank you so much
@Codemycom4 жыл бұрын
@@leoronneland2633 You're very welcome!
@SenthilManikandan4 жыл бұрын
@Leo Ronneland To store e.get(), try using a global list to which you can append to . Then sum the last 2 elements on each button_add() call and export that to global variable to f_num, then this same f_num will be available when you call button_equals().
@johnpro28475 жыл бұрын
Thanks ..helpful
@Codemycom5 жыл бұрын
Glad to help
@AnujKumar-xn5tg4 жыл бұрын
Sir I have also made an Calculator .But can we send this app to others via link or an url??
@Codemycom4 жыл бұрын
Sure...you need to convert it into an exe file first...which can be tricky.
@AnujKumar-xn5tg4 жыл бұрын
@@Codemycom I will try
@AnujKumar-xn5tg4 жыл бұрын
@@Codemycom sir i have convert it into exe file now what is the next step ...
@Codemycom4 жыл бұрын
@@AnujKumar-xn5tg You need to upload it to a website where you can give the link out
@fedos2 жыл бұрын
Instead of getting the current value, deleting it, and then inserting it back with the concatenation, you can just use e.insert(END, number).
@ericgoovaerts2603 Жыл бұрын
👍
@entertainmentdevashishroy27604 жыл бұрын
insert all values as string and use eval function. it will be better
@dopegaming83344 жыл бұрын
dose this works in pychram
@dopegaming83344 жыл бұрын
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: ''
@Codemycom4 жыл бұрын
no idea...I would never use pycharm
@DestoFlix4 жыл бұрын
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.
@DestoFlix4 жыл бұрын
also using linux commands on a windows os confuses new guys even more, cause theyll try them on powershell
@Codemycom4 жыл бұрын
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.
@DestoFlix4 жыл бұрын
@@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
@Codemycom4 жыл бұрын
@@DestoFlix No there is no powershell on linux. Just use the linux terminal. It comes with linux.
@DestoFlix4 жыл бұрын
@@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
@moosman35273 жыл бұрын
you can out the two numbers in a list and add them together
Try and write it in small letters. Sorry for late reply
@marthadeboer44702 жыл бұрын
'Lambda: ' doesn't work. Can I install that?
@Codemycom2 жыл бұрын
Yes it does work, you used a capital L instead of lowercase.
@muruganrg70203 жыл бұрын
What is the mistake in the program it is not showing any error the calculator is opening it is accepting the values but it is not giving the answer I have added my code in the reply section.
@muruganrg70203 жыл бұрын
from tkinter import* root=Tk() root.title("Simple Calculator") #to set the title of the app e=Entry(root,width=50,borderwidth=5) #for search box e.grid(row=0,column=0,columnspan=3,padx=10,pady=10) e.get() def button_click(number): current=e.get() e.delete(0,END) e.insert(END,number) def button_clear(): e.delete(0, END) def button_add(): first_number=e.get() global first_num first_num = int(first_number) e.delete(0,END) def button_equal(): second_number=e.get() e.delete(0,END) e.insert=(0, first_num+int(second_number)) #define buttons 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=40,pady=20,command=button_add) button_equal=Button(root,text="=",padx=40,pady=20,command=button_equal) button_clear=Button(root,text="C",padx=40,pady=20,command=button_clear) #Put the buttons on the 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_add.grid(row=4,column=2) button_equal.grid(row=4,column=3) button_clear.grid(row=1,column=4) root.mainloop()
@learnprogramwithrksingh46054 жыл бұрын
Error f_num is not define in the global scope python
@Codemycom4 жыл бұрын
make f_num global then
@themeow61903 жыл бұрын
my microsoft VS says i got 200 problems... how?
@Codemycom3 жыл бұрын
Who knows. I would never use that tool.
@themeow61903 жыл бұрын
it says f_num not defined. Why? nvm found my mistake
@Codemycom3 жыл бұрын
glad you found it
@adiidan584 ай бұрын
Use: e.insert(END, str(number)) to append text in one command
@Codemycom4 ай бұрын
sure
@JC-qz4pd4 жыл бұрын
when I use .int() it comes up with: ValueError: invalid literal for int() with base 10: ''. But whem i use .float() it comes up with: ValueError: could not convert string to float: ''
@Codemycom4 жыл бұрын
you're trying to pass a string to it...you can't do that. Letters can't be converted to numbers.
@JC-qz4pd4 жыл бұрын
@@Codemycom ok, thank you
@kshitij38264 жыл бұрын
When I try to run it it gives me "TypeError: 'Button' object is not callable " this error. I searched it on stackoverflow and it is not there too. Can anyone help me?
@parth2teja4 жыл бұрын
cross check the code above the # Define Buttons code (all the def and e.grid, etc.) and use proper brackets. It also happened with me and I got it fixed by this.
@kshitij38264 жыл бұрын
@@parth2teja thank you it worked!! : )
@parth2teja4 жыл бұрын
@@kshitij3826 It was the first time I helped someone ;) .
@praveenm91023 жыл бұрын
43 is showing name error name button is not defined
@Codemycom3 жыл бұрын
did you define the button?
@praveenm91023 жыл бұрын
@@Codemycom yes
@rushey_17715 жыл бұрын
Thanks bro🤗
@Codemycom5 жыл бұрын
sure thing
@rushey_17715 жыл бұрын
@@Codemycom bro one help: How to provide entry box for only getting integer input??
@cssflags77714 жыл бұрын
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)
@Codemycom4 жыл бұрын
There are always infinite ways to do a thing.
@monwan3 жыл бұрын
great, thanks
@Codemycom3 жыл бұрын
Welcome :-)
@khizaridrees17584 жыл бұрын
def button_clear(): e.delete(0, END) Dear Sir, I'm facing problem on these lines.
@hiwab413 жыл бұрын
Hmmm try e.insert(0, END)
@xake9954 жыл бұрын
11:52
@alejandronavarro98354 жыл бұрын
Bro, I have to do a calculator with cumulative operations enter by keyboard but when clicking in +, -, *, / the numbers are clear up but the are store for the operations. Example: 2+4+9-3=12 Could you help me please, I need it for 27 please bro ;)
@Codemycom4 жыл бұрын
Don't my videos show you how to do that?
@alejandronavarro98354 жыл бұрын
@@Codemycom Yes yes, but if I enter with keyboard it works? Thanks being so fast :)
@Codemycom4 жыл бұрын
@@alejandronavarro9835 Sorry, I don't understand what you're saying. Enter what with keyboard?
@friiiday_crown4 жыл бұрын
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) + "+")
@Codemycom4 жыл бұрын
Always a million ways to do a thing
@ayushvarshney19254 жыл бұрын
Hey I m getting an error can anyone help me out..! button_clear = Button(root, text= "clear", padx=79, pady=20, command =button_clear) UnboundLocalError : local variable 'button_clear' refrenced before assignment
@Codemycom4 жыл бұрын
you can put padx and pady there, you have to put them in button_clear.pack(), but also you are calling button_clear in your program before you create it.