Threading With Tkinter - Python Tkinter GUI Tutorial #97

preview_player
Показать описание
In this video I'll talk about threading. What happens when your program hangs or lags because some function is taking too long to run? Threading solves that very easily!

Asynchronous threading is something people ask me about all the time. With Tkinter, it's actually incredibly easy to use threading. We'll just import threading and then start a thread whenever we run a function that we know will stall our program.
Рекомендации по теме
Комментарии
Автор

▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My YouTube Channel:
▶️ See More At: ✅ Join My Facebook Group:
▶️ Get The Code

Codemycom
Автор

You have great tutorials! In my humble opinion If you do not want to start 5 second counting automatically I think you need: my_button1 = Button(root, text = '5 seconds', command= lambda:

peterpacsay
Автор

Man, i literally find everything i'm looking for on your channel, thank your very much for this video.

holycow
Автор

I think it's better to use instead of because the latter will run five_seconds in this very line while the former will not. Most cases, you don't want the command to start until the button is pressed.

edit: Also this doesn't work when you try to press the "Wait 5 sec" button twice. You will get: RuntimeError: threads can only be started once. It feels almost as though you hid that fact by only demoing the functionality by closing and re-starting the program instead of clicking the button multiple times? Feels like an unfinished tutorial.

evanlavizadeh
Автор

I think he didn’t notice ! the 5 seconds button was automatically pressed by the >> .start() << and it just allowed to work just once. But thanks for the suggestion and solution from the community 
>>>command=lambda: <<< fixed the problem 👍🏼👍🏼. Anyway thanks John! Very good material👍👍 😁A good marksman may miss

eddw
Автор

Wow this is excellent! I am developing a FinTech payment processing application and I am at the point where threading is very necessary. So simple. Great teacher-instructor. Thank you! Going to to apply this to my notebook/tabs where my application is split out logically and may hang the rest of the program if a single threaded. Love these series of Tkinter. Wish I would have found these a 1yr ago. I am now a Tkinter junkie.

frankrogowski
Автор

Don't know if you encountered this rather peculiar feature but:

When wrapping my button event to my thread I noticed that: target=("function").start() will cause the event to run on the start up on the program
However if I change it to the following: target=("function").start then the event will now run on the button click

joelmanning
Автор

Incredibly easy way to get this done! I've been looking for a way to get a tkinter GUI to stop freezing on long tasks, and this does it perfectly! Thank you!

raoulalfonze
Автор

Best channel for python on YouTube. Why aren’t people subscribing to this lovely channel?

fernandocorenstein
Автор

You are amazing, man, thank you so much!

If someone is having a problem where the function "start" starts before, just put the lambda before threading.

This is my situation:

enter_button = Button(frameRadio, text="ENTER", bd=0, bg="#005C7A", fg="white",
font=(font_type, 10, "normal"), command=lambda:

danilodelucio
Автор

Great guide! Now I'll never forget to give a widget pady=20 to push it down a little bit.

bitMario
Автор

LOL the last few days i have been writing a program with a while loop in it and it caused me ALL KINDS of problems. In the end i restructured the entire thing so I didn't need the loop...

I was only 3 vids away from this video in the playlist ;|
Wish I had watched this first. Woulda saved me about 12 hours. Google sent me to StackO the posts I saw mentioning threading mostly said 'dont do it, its complicated, work around it'.
Great tool and now I understand it. Thanks!!

RyanDanielG
Автор

You are great sir....you are you thank you so was just stuck there for about 2 you

darshanpanchal
Автор

The best video about treading i ever seen

captainmacro
Автор

A super simple explanation that works, top stuff!

nebular-nerd
Автор

That iconic: and we'll give this a pady of 20 just to push it down a little

andrejvujic
Автор

Thank you for your time to help us small developers improve our software, you are a real hero.

insertxk_dev
Автор

your videos and website have helped me learn so much. thanks john!

michaeltennyson
Автор

Omg I was searching so many forums for this solution.... thanks thank thanks

uninho
Автор

Great videos. Thank you. I just replicated your code but in my case, the function starts automatically before I click the Button. what am I missing !!
start = Button(frame, text="Start",

bobzarrabi