Keyboard Event Binding With tKinter - Python Tkinter GUI Tutorial #44

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

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

  • @aakashahlawat4267
    @aakashahlawat4267 4 года назад +33

    Working on a project currently.
    This series helped me to go through a lot of new concepts and design my front end my own way.
    Thanks a lot sir 🤗🤗

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

    You and RUclipsrs like you are doing a Great Job Providing Quality Courses for Free.

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

      Thanks for watching

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

    You teach bind event so nicely.......I have a problem with this topic...but now totally clear....Love you a lot.......

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

      Awesome, glad you were able to find what you need!

  • @priyanshusaxena7157
    @priyanshusaxena7157 4 года назад +5

    All these videos really helped me a lot while working on a project.
    Thank you so much sir!!!

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

    fantastic tkinter tutorial.Bunch of thanks John Elder

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

    ▶️ 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

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

    Hooo hoooo!!!! Man this video was very awesome and BTW I really liked the bind function! It's amazing!

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

    Man you clear my mind regarding to bind() function thanks alot INDEED YOU ARE A GOOD TEACHER!❤

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

    Thanks for making my internship period easy!

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

    Congrats on 50K! I just checked today and it was at 49.9K.

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

      Thanks! It's pretty exciting!

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

    Thank you SO much.

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

    what do you do if you have multiple buttons in the window and you need to specify a particular key to hit a specific button
    in that window. If you could help me with this it would be a lot greatful

    • @ba.youtube1007
      @ba.youtube1007 3 года назад

      same question, have u already find an answer? i need it too pls

  • @mrinalpradeep7052
    @mrinalpradeep7052 4 года назад +12

    Also can you specify a particular key to the button so that when you hit it it clicks

    • @ba.youtube1007
      @ba.youtube1007 3 года назад

      same question, have u already find an answer? i need it too pls

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

      @@ba.youtube1007 hi i couldnt find answer also

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

      I think I figured it out. Seems as if you type, "window.bind(, func)" Where window is your window name, c is the character name, func is the name of your function

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

      @@calebfoxschool yo thank you so much, ive been looking for an hour for this solution, and you just helped

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

      @@calebfoxschool thank you so much, you just saved a project i've spent hours trying to troubleshoot!

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

    Eagerly waiting for your dropdown video tutorial. :)

  • @tarunsukhpalani9514
    @tarunsukhpalani9514 4 года назад +15

    I trust you, you don’t need to show which click you done 😅🐒

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

    Thanks I wanted to learn this thing ,u read my mind

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

    Thanks a lot for this wonderful series.

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

      Glad you're enjoying it!

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

    wow gunius... it's very fun learn code with him... thank you... it's so useful! :)

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

      Glad you're enjoying it!

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

    brillant work sir

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

    You are AMAZING, subbed.

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

    Thanks a lot sir! Great tutorials!

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

    Thats a hell of a word "BOOM"🥰🥰❤️❤️❤️

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

    Hey man love your videos, thumbs up.
    I just one question though, on creating this event the original function ceases to work.
    I have an exercise where my Spinbox has the command function but I also want the return key to work to call my function. However when I create the even, my spinbox command call stops working and creates an error of ,
    TypeError: unit_price() missing 1 required positional argument: 'event'
    So was wondering how I can incorporate both into my program. Hope you see this, thanks again.

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

    How to use my own event instead of ""? I have a video. I go through video frames and perform some operations on the frames - after these operations are done, I want to update the image in tkinter window. How can I achieve that? Thanks.

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

    hi, I have designed a Entry forms in my desktop but in want to run it in a windows tablet too. But in input field it is not automaticaly offering a keyboard. How could I deal with the issue so that program with provide a keyboard only in tablet otherwise in desktop Normal keboard. thanks in advance

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

    thanks so much you are a real lifesaver💙

  • @ba.youtube1007
    @ba.youtube1007 3 года назад

    how about when there is multiple button, for example "Button A", "Button B" and I want to hit that Button A with num1 and Button B with num2.... Here u need to press Tab to focus on the button but how about a specific key on a specific button? i tried making calculator and i want to add a feature where I use num pad instead of click to the numbers.

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

    These videos are amazing

  • @TO-il3vc
    @TO-il3vc 3 года назад

    These bindings don't seem to work with the combobox widget. Is there a way to get them to work with it?

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

    really awsome

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

    What if you want to be able to press the button or hit enter?

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

    Can we pass more that one event in there like a Tab keystroke and a button-1 keystroke ?

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

    Thanks, are there any options to pass paramters into the binded function like when we call functions/methods normally?

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

      sure, in the normal way you pass a parameter into any function.

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

    Is there a way to make custom "" events? I am trying to integrate a raspberry pi Sense Hat joystick as input but I am having trouble getting it to connect

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

    can you combine keys such as: s + button1 ?

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

      One way or another, sure...depending on what you mean.

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

    First of all thank you for clear tutorials.
    I do have a question though. What if I wanted to put event into thread?
    For example if you try replacing clicker inside of bind() into threading.Thread(target=clicker).start() it will give "TypeError: clicker() missing 1 required positional argument: 'event'". Is there a way to fix it or go around it?

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

      pass in your even to clicker(e)

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

    Can you bind more than one event to the button? Like, if you right-click, I bring up a help window? But, if you left-click, I bring up the data you submitted?

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

      Sure...I think so lol I've never tried it, but I don't see why not...

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

    how to check if mouse is pressed on screen and not on button

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

    John is it possible to disable double click mouse event after using it then enabling it using a button ?

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

      Sure...just use a counter to count the number of times you've done it...

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

    Should I use python tkinter Or pyside for a attendence management application. By the way ur tutorials are great helped me in creating great gui

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

      No one can answer that but you, you're the only one who knows what your program requires and your skills in each one.

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

      What would u suggest if I am beginner at both??

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

      @@robinsajan9656 Pick one and start using it.

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

    How do you control the detection rate ?

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

    Gow is it possible to track keyboard and mouse event outside the tkinter window means if tkinter window is minimized and we are working on other screen window or application then it should auto detect that key is press or mouse is moved

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

      I don't have any videos on that

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

    Hey. I really need help.
    I have few Labels that suppose to change color when u hover mouse over it.
    I use bind bc I haven't find any other way to use widget like Label interactive, it also react on click, and do particular stuff.
    My problem that when I create a function for changing color, I must make 2 functions - on is other and I have at least 3 labels, so it has to be 6 function. That looks very long and unprofessional.
    I was trying just to run code like LabelName.configure(bg="red') instead of handler but it doesn't work. It accept only commands - function. And it pass in that function - event. So i was wonder is there a way to make 2 function and somehow pass in them name of the widget which pretty much an object than use it to execute color change code?

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

      1. who cares how it looks?
      2. Sure, you can use a lambda to pass in the widget itself or some sort of identifier that you can use in your function with logic to do whatever you want. Google: tkinter bind pass arguments (or something like that)

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

      @@Codemycom 1. I care. I wanna be a pro. eventually. So it is always a good idea optimize code.
      2. Yes. we used [lambda: function] before. All i had to do is just make single line function instead and it worked. I just add name of the function and it start working. Looks like this Labelname.bind(, lambda x: Labelname.configure(bg="red"))
      It's not exactly what I wanted though. I wanted to write X.configure(bg="red")) only once and just send name of Label widget into X.

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

      @@maxwellhawk pro's are the sloppiest coders out there lol no one cares how your code looks.

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

    Awesome job.. Thank you!

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

    Sir, is there any way that we can bind all the keys the same function. If, Yes provide the code..

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

    Missed ur Django series John..

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

      How so? I've got a ton of complete django videos on the channel already...

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

    what you mean most mice don't have middle button anymore. All mice I have use has middle button.

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

    Hey John, can you please tell us about unbind part of this. I am trying to bind enter key to multiple Entry widgets one after another. I am using barcode scanner and it auto-enter after scanning the code.

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

      You can use the .unbind() function in the same manner you used the .bind() function to remove binding.

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

    Dear how can i do right click inside Entry (Textbox)?

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

    This is just Awesome...

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

    good sir all events are working only one is now working

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

    Instead of the event going to a Label, could it just change the Font color on the button?

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

      sure, you can do anything you want

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

    Event should occur as long as key is pressed or button is clicked ie button is hold on

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

    Sir how can i detect key FN? Thank you!

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

    I'm trying to bind a button to the windows key. the little button with the flag on most keyboards. I cannot find a legend of all the key bindings. I am wondering if anyone knows where to find a full list of all key buttons and their associated id's?

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

      none that I know of

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

      @@Codemycom I ended up using a module that automatically press his buttons for you I think it's called something like pyautoGUI
      That module had a legend that described all of the different keyboard buttons that it can press for you and so on button press I told it to do the windows key. I'm trying to see if I can build the entire Windows 98 operating system on top of Windows 10. it's definitely not going to act like Windows 98 but if I can make menus and sub menus that can be linked up to Windows 10 functions it could be a very nice theme I already finished the taskbar and I linked up a button to classic shell which has been a complete immitation of the Windows 98 start menu it even has MS-DOS except instead of opening a ms-dos said it opens up the terminal
      The only thing I have not figured out so far now is how to get the Windows 10 applications that start from the fake Windows 98 overlay program I'm trying to makedo you have the Windows 98 gradient title bars and the old school minimize maximize and close buttons because the modern Windows 10 title bars keep appearing whenever the fake Windows 98 application calls the Windows 10 programs to open. I managed to change the color of the title bars to that blue hue but the gradient is not available in Windows 10 apparently so I've been trying to find a way to fake it by maybe finding a python module that can display a Windows 10 program running inside of a widget this might not exist though

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

    how would I do something while the key is being pressed

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

      Isn't that what this video shows?

  • @DAX-00
    @DAX-00 3 года назад

    when I change "< Button-1 >" to "< Button-3 >" nothing happend. ¿what would be the reason?

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

      The reason is you changed it

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

    You used tab to select the button can we avoid that if I have multiple button most of them are clicked based but some of them are key based

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

      Not sure what you mean...

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

      @@Codemycom in keyboard binding I want to use a button without Using Tab key to select it I may use other button to select the button

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

      @@chinmaykulkarni7835 hope u would have got the answer, if True:
      pls_help_me()
      else:
      print("HI")

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

    when i run my project i got error. why?
    AttributeError: 'NoneType' object has no attribute 'bind'

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

      You have an error in your code.

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

    Can we add a Confirmation Message Dialog box ("Do you want to Quit " yes or no), like this in the Above Red close button in the Form

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

      You can do anything you want, of course

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

      @@Codemycom Can you Please guide me For the same , how to ?

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

      @@parassah9714 I have videos on the playlist about message dialog boxes.

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

      @@Codemycom thanks 😊

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

    am working on a project in which i have to insert an entry into the second entry depending upon the first entry is binding can be used for entry widget too ?
    FOR EXAMPLE if user enters 2 in the first entry, the second entry should automatically update square of 2 in it. I want to solve such thing in my project without clicking any buttons? kindly help me sir No one in this world is teaching me tkinter except you

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

      Yes you can use binding for anything.

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

      @@Codemycom thx i tried, and i got it done
      def ins(e1):
      entry2.insert(0, e1**2)
      entry1=Entry(root)
      entry1.pack()
      entry2=Entry(root)
      entry2.pack()
      entry2.bind('',lambda a: ins(int(entry1.get())))

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

    thanks!

  • @saiyed722-tp5sd
    @saiyed722-tp5sd 9 месяцев назад

    thank you sir

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

    everything was alright. I have bind("", myfunction) and when i pressed right button of my mouse it was working but when i left click on it after binding right key it was poping up a TypeError.
    what should i do now. : (

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

      Did you pack and design something on the same line?

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

      i am unable to install pyinstaller with pip. : (

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

    can u continue handlebar js with node js course

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

      I have a course on that at codemy.com

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

    Sir can we add a command to an entry box?.....Like in the registration form, after the user fills every input and then clicks the return key(without getting the tab on the button) it automatically calls a function?
    Sorry to trouble you once again!

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

      You need binding...I touched on it in a video but didn't talk about entry boxes

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

      @@Codemycom So is it possible to add a command to an entry box?

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

    Membership Button is NOT showing in RUclips PAKISTAN 🇵🇰

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

      What membership button?

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

      @@Codemycom I was talking about your second channel #Freecodecamp.org . I saw a red JOIN button under your video on RUclips with SUBSCRIBE button, and that button disappeared when I visited the same URL without Canada Proxy.That button was actually for channel membership for CA$4.99/month.

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

      i am talking about your's this video ruclips.net/video/YXPyB4XeYLA/видео.html

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

    Thanks so much

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

    Thumbs UP!

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

    Can we use an Entry function instead of a button?

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

    can i do the bind function on a tkcalendar?

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

      Not sure, give it a try and see lol I don't see why not

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

    it was helpful : )
    but i dont know name of buttons
    how can i find name of buttons

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

      You're the one who names them...how can you not know the names?

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

      @@Codemycom yes like i dont know whats the name of delete button in binding i mean stuff we write in

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

      @@amirmohammadk745 Try this: stackoverflow.com/questions/32289175/list-of-all-tkinter-events

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

      thank!!

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

    When I put event in my argument of my function it remains gray instead of changing orange does anyone know why?

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

      You’re using a different text editor, they all act differently

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

      @@Codemycom my apologies, i should have specified further, it is not recognizing the argument as anything special. It thinks I am just passing a regular argument for my function

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

    I’d love to know if you could give some advice on how to make money with python , or how or if one can be certified with it . I lost motivation to learn to code but I feel like if I had a goal it would me easier to stay motivated

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

      There are infinite ways to make money coding...I have a playlist on that topic on the channel...also, you can always just get a job as a coder, right?

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

    sorry is not working

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

    What does tabbed mean at 9:09

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

      the tab key on your keyboard

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

    this is 3 years old but what is this man i search tkinter keyboard event i watching button + keyboard event.? why button?

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

      huh? Because it's a mouse button...right?

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

      @@Codemycom no my question keyboard key like enter key 6:52 btw there is way no BUTTON only keyboard keys ?

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

      @@GnuChanOS sorry I don't understand anything you're saying

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

    Is it only me or this guy looks like Walter White from Breaking Bad?

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

    I don't know why but I feel like im sitting in front of him

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

    Can I get pinned for no reason?

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

    I usually like your videos but this one was disappointing. Why use a button to demonstrate binding. You don't need to bind a button since in actuality 'command' technically binds it to a function, anyway. What about the 'Up' or 'Down' keys or the many keys that one would want to bind?

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

      lol I have videos on that.

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

      Don't get me wrong, I love your videos. Actually, I purchased the courses 2 days ago. Thanks for the education.

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

    Thanks a lot for this wonderful series

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

    Thanks a lot