Tkinter - Multithreading

preview_player
Показать описание
I'll show you how to use multi-threading with Tkinter. We'll look at how to communicate with the main GUI thread from a second thread. Multi-threading is an important topic for Tkinter applications that have any kind of network feature.

Please consider supporting my work with your donations on Ko-fi:

Multithreading with Tkinter.

0:00 Intro
1:30 Demo application
2:55 The issue
3:36 Create a window
5:24 Create a frame
8:08 Create a progress label
8:55 Download method
10:33 Frozen window
12:23 Create a separate thread
15:46 Demo of separate thread
17:17 Communicate from second thread to first thread
21:00 Create ticket queue
26:49 Notify main thread to check queue
29:12 Check queue method
32:26 when= argument for event_generate()
33:25 Continue checking queue
34:03 Demo application
35:32 Showing a download has finished
37:17 Closure

#tkinter #tkintertutorial #multithread #pythongui #pythonguitutorial

event_generate()
Рекомендации по теме
Комментарии
Автор

Excellent tutorial, thanks to you I now have responsive tkinter apps with long running tasks. I was never able to figure this out and I just couldn't get my head around other multi-threading tutorials, but you made this subject crystal clear. You are a superb teacher.

kharaktur
Автор

I was trying to convert audios from video files. That means converting music videos to mp3 media files in bulk. So I have to display extracted mp3 names and total number of processed files as it goes. Your tutorials helped me achieve this goal. Thank you very much.

FufaTujuba
Автор

This video helped me immensely when writing my first multi-threaded application with customtkinter and queue. Much appreciated. I will be subscribing for future content.

smittyIT
Автор

Maybe the application works like the video shows, but when you close the app, is very frequent that the kernel crashes, showing a message with something like "another thread try to change something in the main thread" because GUI is no thread safe. This is a very good solution to this issue, and is another good example of why the OOP approach is the best way when your application needs to do interesting things.

el_munoz
Автор

So good. Your channel will be very popular.

idopshik
Автор

Good work sir🎉.
You have earned a new subscriber!

I especially love the way you follow foundamental coding standards and best practices. You are teaching us to do it the write way, unlike most of the other tutorials.
This is important because most of us are self taught and not CS graduates.

georgewairobi
Автор

Briliiant, well explained - well paced. thank you Jobin !

daniliser
Автор

Another great tutorial clearly taught. Thanks for sharing.
The comment at the end is so true in that most any GUI development will present this problem.
The problem is the same for example with developing GUIs in Windows using things like MS Visual studio creating GUI applications. Whether using WPF, or the old Winforms approach one needs to implement threading in order to deal with this problem of long running processes freezing up the GUI and all it's controls until the process completes.

fredflintstone
Автор

Is this code available for download anywhere? It would make a great starting point for a project I'm working on.

MrPragmaticLee
Автор

Great video, Thanks for sharing the knowledgs

johnstoddart
Автор

This tutorial moves Tkinter from a cute GUI tool to something incredibly useful for real world applications. I need to utilize grid geometry, so it's going to take me a bit to modify your tutorials from using the pack method to grid, so hopefully I won't go down a rabbit hole. If you have any pointers on grid geometry and threaded applications, I'd appreciate it!

bastionjordan
Автор

Nice! Really useful and helpful. Thank you!!

kychemclass
Автор

Very helpful video, I have been looking for how to do this, this info is probably found nowhere else .. in a video format.

asrajan
Автор

Great tutorial. It’s exactly what I’ve been looking for guidance on. But, if tkinter is not thread safe, what makes it safe to send the event from the child thread? Should the “after” method be used to poll the queue from the main thread instead?

scotteebee
Автор

you have got a new subscriber! You have really nice teaching skills! But there is one thing, i don't really get. Why are you creating a new Ticket Instance for every loop? Shouldn't this be only one object with states updated? Maybe i am missing something or i don't get the purpose of the program. Otherwise, great stuff!

legion_prex
Автор

I'm a beginner who learned a lot from this but there was one thing which I was wondering : you used auto to generate a type for the tickets in your queue, if I understand correctly, but this value what is it exactly? Is it always a string? Thanks

andromilk
Автор

I love you man.. very very nice tutorials.. thanks big time..

ET-ffry
Автор

How would I redirect sys.stdout and sys.stderr to another text widget in the program. Would I have to make a new class or could I use the ticket system

WhiteError
Автор

@jobinpy i am trying to create GUI using tkinter but i am facing very much GUI crashing issue. Please do video on this topic. Thanks in advance.

bhagyeshwargavekar
Автор

How would I make a button to cancel the download (cancel the secondary thread)?

mrkalvinbs