Progress Bars With Tkinter - Python Tkinter GUI Tutorial #78
In this video I'll show you how to create a progress bar with TKinter and Python.
Progress bars are important for most applications. In this video we'll look at the ttk progressbar widget. I'll show you the two modes, determinate and indeterminate. We'll look at several different ways to use it, and also how to determine where the progress bar is at any given time.
Пікірлер: 140
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My KZread 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
@techdiyer5290
3 жыл бұрын
thanks :)
@pramilamenon8621
2 жыл бұрын
i have a question, how do i make the progress bar colored? like as in making the middle green part colored to blue or red?
@Codemycom
2 жыл бұрын
@@pramilamenon8621 Use a style element. Google tkinter style
You are amazing. I have been googling my bum off and you just solved all my problems for me and the ones I didn't even know I had yet. 100% recommending you to absolutely everyone I know
@dragoneater2008_
3 жыл бұрын
I was looking for this too!
Thanks sir, this will be helpful for a little project I have. Really easy to understand!
@Codemycom
3 жыл бұрын
Glad it was helpful!
😍😍😍 I love it Thank you so much Mr. Elder
@Codemycom
4 жыл бұрын
You are very welcome
Hi John I'm running a progress bar(which is set up as a class object) for an very large process which I want to split up into different functions, essentially it runs as follows 1. Process text files updating progress bar with each file processed 2. Read in excel files and extract desired info and update progress bar with each sheet processed 3. Compare the text files with the excel files 4. Repeat 1-3 for a different type of file 5. Post all results to an output file. I would like to split up steps 1-5 into different functions within the progress bar class funtion.
Thank you sir You are the best i learnt lot of things from you.
@Codemycom
4 жыл бұрын
Glad to hear that!
nice tutorial, thank you Prof John
@Codemycom
3 жыл бұрын
You are welcome
your videos are the best
@Codemycom
2 жыл бұрын
Thank you!
Hit that like button Python Fans! Great tutorial. Feed the Algorithm!
Hey John, very neat feature! I was just thinking about how a progress bar's value could be updated dynamically in reference to some function (bound to a button). So for example, once the button is pressed, the progress bar is initialized to 0, but as the function is being run, the progress bar is moving along with it. Once the function is done executing, hence the progress bar reaches 100% and spits out the function's result. How would that type of functionality be implemented? Thanks, Safwan
Dammit! I broke the LIKE 👍🏻 button! I "SMASHED!" the like button too hard because of you, John!
@Codemycom
Жыл бұрын
Perfect! lol
This video needs more likes than it has
@Codemycom
3 жыл бұрын
I agree, tell your friends!
Thanks a lot again!!
@Codemycom
4 жыл бұрын
Thanks again for watching!
@sidhumm
4 жыл бұрын
You are the Best!!
Thank you 😊
@Codemycom
Ай бұрын
You're welcome 😊
Thank you sir
@Codemycom
2 жыл бұрын
Welcome
Vídeo Muito bom, vou usar essa barra de progresso para questinarios ou mesmo como tela de login
@Codemycom
4 жыл бұрын
Glad you found it useful!
Really loved the tutorial but can you change the colour of the progress bar?
The video is amaizing nice thnx
@Codemycom
4 жыл бұрын
Glad you liked it
Thanks John for this; your video series has been super instructive. I'm running into a problem in using the indeterminate mode of the progress bar--I start it at the beginning of a task and close it at the end of that task before informing the user the task is complete. But when the task actually starts, the bar freezes in place and doesn't start back up. I tried putting it in a separate window and the same thing happened. I read the issue might have to do with "threading" or multiprocessing, but I wanted to see if you had any advice. Cheers.
@Codemycom
4 жыл бұрын
Yeah it's probably the threading thing...but slap a root.update_idletasks() in the middle of there somewhere and see what happens...
@parkerlumkes8686
4 жыл бұрын
@@Codemycom the update idle tasks seems almost temperamental; sometimes it works, other times not. I decided to do determinate and attempt to update the status bar when a certain percentage of the task was completed. However now I'm running into a separate issue, seemingly, where after the bar gets to 100%, if I want to reuse it, it doesn't seem to want to go back down to a lesser value. I looked around in vain for a reset or a set, or even status['value'] = 0, but the bar just stays at 100% even if I use the exact same methods I used to grow the bar. I know that's weedy, no worries if you don't know off the top of your head.
Found a thing makes me confused: When I define the progressbar using a new line for ".pack()", it works, once I use the cascade formation link "ttk.Progressbar().pack()", there will be an error, and the error is about the 'value' in the setp founction.
@Codemycom
2 жыл бұрын
Yeah never pack a thing on the same line that you define it.
Hi John, Thanks for the video, I have a question if you can help, I have some code that converts a text file to MP3 and I want to use the progress bar to let the user know that it's still processing. I'm using these 2 lines to convert but want to show progress while it's doing it. tts = gTTS(text=remove_non_ascii_2(txt_content), lang='en') tts.save(mp3_filename) Any suggestion? Thanks.
@Codemycom
4 жыл бұрын
Sorry, no..I don't know what gTTS does...
@kwilla2001
4 жыл бұрын
gTTS is just a google python interface for google text to speech API. I was mainly trying to find a way to make the progress bar work in parallel with something else that is running in the code, maybe like while downloading a file etc. I'll keep looking online. Thanks for your reply.
Can we change the color of the Progressbar ?
i conclude that when i import "ttk" the appearance of button also changes. : \
How can I use if statements with the progress bars?
@Codemycom
3 жыл бұрын
Any way you want...I have more videos using them in the playlist I think...
I have a question. Generally, the external software will jump out of a new window and then run, and it will automatically shut down after running. What should I do?
@Codemycom
2 жыл бұрын
Sorry, I don't know what you're referring to.
Can we make a root window in which there is no title bar as we can create with c#
@Codemycom
4 жыл бұрын
maybe
👍👍👍
@Codemycom
4 жыл бұрын
Thanks!
sir, how to change color of progress bar
Hi john, after going through your tutorials I made a tkinter software for accounting ..everything worked out well.but when I was testing to find errors... I found one problem that if I enter a number with zeroes at the starting and make the calculation then I get wrong result...FYI I initialised the textvariable of entry boxes to doublevar() ..I surfed internet and found no one had such problem...is this an inbuilt tkinter problem...Can anyone please help me fix this error.. eg: 20(in a box) * 1(in another entry box) gives 20..which is perfect but 020(in a box) * 1(in other box) gives result as 16
@garrybeck216
4 жыл бұрын
Putting zero at the front, tkinter(and I think Python) reads it as an octal integer, so 020 is 16 in base 8. Sorry, do not know a work around. But now you know the problem you may successfully research it.
@Codemycom
4 жыл бұрын
Sorry I've never seen that, not sure how to fix it
How do i set a max value to my progress bar? let's say i want it to be full at when the value equals to 1500? and how to i sum values into it as a number, let's say i wanna add 15 to the bar i just mentioned instead of adding up % of the full value as you did in the video, how can i do that?
@Codemycom
Жыл бұрын
set the maximum to 1500. The video shows you how to add 15 to the bar.
hello sir...i wanted to ask one thing..the moment the progress bar starts on its own..no buttons or label works and on being clicked, it says not responding..why is it so?
@gabrielez433
3 жыл бұрын
i have te same issue i think it has something to do with root.after but it doesn't work for me
@bhavyagosai6712
3 жыл бұрын
Check out the Threading concept kzread.info/dash/bejne/nKKmpdJ6YduwgLQ.html&ab_channel=Codemy.com
Sir, how to make entry fields rounded with tkinter?
@Codemycom
3 жыл бұрын
No real easy way to do that, as far as I know
Hi John, i'm following all your videos and i'm learning a lot. with this one i have an issue with indeterminate , its showing the bar in full. and the other issue is when i use the timer, the root screen froze and shows the bar in full after 10 seconds. I'm using mac, can you please advice what i'm doing wrong. thank you!
@sandeep-shaw
3 жыл бұрын
I faced the similar problems too in windows. I was using it with the concept of class and it didn't work. . [But this code made it run👇👇] . However I am made this mistake 1) I packed it together with the widget. 2) I use the code : ============================== def loader(self): for i in range(100): self.progress.configure(value=i) self.update() time.sleep(0.05) self.destroy() ================================== . . I hope this helps🙏
@ragheedmaloyan3730
3 жыл бұрын
@@sandeep-shaw Thank you, after another try its acting different this time :) but I guess its required to install more libraries to your programing software, I'm using Pycharm. Thanks again for your advice.
@sandeep-shaw
3 жыл бұрын
Sorry to hear that sir, . I didn't consider that, I was using VISUAL STUDIO CODE. . Hope that you able to find your solution very soon. . Best of Luck🙏
@ragheedmaloyan3730
3 жыл бұрын
@@sandeep-shaw do you recommend using that? btw, I'm trying to learn this and i'm working on gui showing photo on a time of event. any idea can help me? I really appreciate any advice :)
Is it possible to bind a progress bar to a function and that way, when the function completes its execution, the progress bar will complete and actually make sense and be of use instead of just a decoration! :)
@Codemycom
3 жыл бұрын
Of course
@dimitardimitrov8002
2 жыл бұрын
@@Codemycom Could you share a link for how it's done
@Codemycom
2 жыл бұрын
@@dimitardimitrov8002 I have lots of videos on the playlist on binding things, look around
Please, Please :S I´m creating a simple memory game, random numbers in a sequence ... in shell run OK, but I like blink buttons to indicate, I don't want to print my list, only blink buttons. I spend 3 days but it still fail. (example: it's possible change ►bg="red" ►time.sleep(1 ) ►bg="blue" ►time.sleep(1 ) ... create a blink button)
Hey! I'm using 2 progress bars in something I'm making, is there a way to change the progress's colour instead of green?
@Codemycom
3 жыл бұрын
Yeah but it's tricky. I didn't try this, but just copied it from stackoverflow: TROUGH_COLOR = 'blue' BAR_COLOR = 'green' style.configure("bar.Horizontal.TProgressbar", troughcolor=TROUGH_COLOR, bordercolor=TROUGH_COLOR, background=BAR_COLOR, lightcolor=BAR_COLOR, darkcolor=BAR_COLOR)
@wellitsasecret6547
3 жыл бұрын
@@Codemycom Thanks for getting to me so fast! I will try this now :)
@Codemycom
3 жыл бұрын
@@wellitsasecret6547 Good luck, I'm not sure it will work :-p
@wellitsasecret6547
3 жыл бұрын
@@Codemycom I wasn't quite sure how to use that, but it gave me an idea of what to look for, and this seems to work blueTheme = ttk.Style() blueTheme.theme_use('clam') blueTheme.configure("blue.Horizontal.TProgressbar", foreground='blue', background='blue') playerEnergyBar = ttk.Progressbar(window, orient = HORIZONTAL,style="blue.Horizontal.TProgressbar", length=350, mode = 'determinate') It changes the color but also the style and look of the bar slightly
@Codemycom
3 жыл бұрын
@@wellitsasecret6547 Nice!
Hello Sir! I tried this but unfortunately it returns me an error like "module 'tkinter.ttk' has no attribute 'ProgressBar'"! I dont know what to do! Could you please help me out!
@Codemycom
3 жыл бұрын
you have a typo somewhere
@ij1316
3 жыл бұрын
It's a lowercase 'b' in Progressbar
Thank you very much I made a GUI using your tutorials . The GUI looks good but I now have a big problem on text widget I want to redirect my the outcome from my console to text widget may you kindly help me or create a tutorial for that .
@Codemycom
4 жыл бұрын
Sorry, I don't know what you mean
@ntcellulartutorials1195
4 жыл бұрын
@@Codemycom I do cellphone flashing and unlocking ,so I made a tool that utilizes adb and fastboot commands using tkinter , for example I read cellphone IMEI number in fastboot mode us the os module . Now the problem is the results are showing up on the pycham terminal instead of my gui text widget.
@ntcellulartutorials1195
4 жыл бұрын
@@cool-cloud thank you very much I am going to do try that in my project
Can we notify the user when new blog posted (web push notifications)? If yes pls make video on that.
@Codemycom
4 жыл бұрын
I think you maybe posted this comment under the wrong video
@freekeys
4 жыл бұрын
@@Codemycom i know but I can't wait for right video so i commented just to give u a msg of that😅😂
Is there a way to destroy the progress bar if it reaches the end or progress['value'] == 100? I tried the following: if progress['value'] == 100: progress.destroy() But it doesn't work....
@garrybeck216
4 жыл бұрын
Don't know why this is a problem for you, I've tried it and it works for me. Is there a syntax or typo error in your code?
@Codemycom
4 жыл бұрын
yeah that code works for me too, there must be a typo in your code. You can also try 100.0 (instead of 100) did you name your progress bar 'progress'?
@IQUBE
4 жыл бұрын
@@Codemycom Yeah the progress bar's name is progress. Anyway nice video
@IQUBE
4 жыл бұрын
@@garrybeck216 Nope. I double checked the code.
@akarshgupta2586
3 жыл бұрын
does your code ever produce the value 100?
Is there any way to use OOP with Tkinter?
@garrybeck216
4 жыл бұрын
Yes, I write all of John's programs in OOP. Use a Main class to set up the root window and a class (say-ProgressBar) for the body of the code. Create an instance of ProgressBar in the Main class.
@Codemycom
4 жыл бұрын
Sure
can you please help me with a programme
Is there a way to connect this progress bar with the pytube progress bar?
@Codemycom
2 жыл бұрын
I don't know what pytube is
@derpiesaurus
2 жыл бұрын
I hope your not still looking after 3 weeks, but if you are: def percent(tem, total): perc = (float(tem) / float(total)) * float(100) return perc def downloadCountProgress(stream, chunk, bytes_remaining): size = stream.filesize progress = (float(abs(bytes_remaining-size)/size))*float(100) downloadProgressbar["value"] = progress # This is your progress bar progress = int(progress) downloadPercentage.set(str(progress) + "%") root.update() add these two functions and then add "on_progress_callback=downloadCountProgress" to your youtube url thing, like this: yt = KZread(KZread_URL_HERE, on_progress_callback=downloadCountProgress)
@TipsTricksSolutions
2 жыл бұрын
@@derpiesaurus Oh thank you I will try it tomorrow..
thx bro i needed the root.update_idletasks() thingy
watching this video solved my issue of my function not displaying whats happening as its doing it
@Codemycom
Жыл бұрын
Glad to hear it!
When i press start button I'm unable to use any other widget of app. How can i solve this??
@Codemycom
3 жыл бұрын
use threading
@kanwaradnan4849
3 жыл бұрын
@@Codemycom yes I watched you're video of threading.. It solved my problem .. Thanks a lot
Sir, can you lease make a video on ttk theming ?.
@Codemycom
4 жыл бұрын
Yeah I might do that eventually
@ClusterSeries
4 жыл бұрын
@@Codemycom Sir, Is it possible to modify an existing ttk theme ?
I couldn't assign to progress['value'] shows as none type
@Codemycom
3 жыл бұрын
Did you pack and assign your widget on the same line? You can't do that
@adarshs7982
3 жыл бұрын
Ok thanks
Hi Danial, I am a retired engineer in the UK in lockdown using the time to learn Python. Is it possible for you to explian how to read an IOT device such as the ESP8266. I can read the output by placing the IP address in the browser window. This returns the tempterature of say my Greenhouse. I have several other IOT units around and would like to build a GUI to read them all. I think Python would be perfect for this. Thanks Len Beasley
I Keep getting the error "from Tkinter import ttk ImportError: cannot import name ttk" im using the same editor can anyone help me with this please
@Codemycom
3 жыл бұрын
tkinter needs to be lowercase
@danielrooney9945
3 жыл бұрын
@@Codemycomthanks for the reply i tried the small t and a capital T in other code and the capital T is the only way i can get the code to run
@Codemycom
3 жыл бұрын
@@danielrooney9945 no sorry that's just not right... are you using different tools than me or something?
How do I make a python tkinter downloader with a progress bar?
@Codemycom
3 жыл бұрын
Downloader of what?
@dragoneater2008_
3 жыл бұрын
@@Codemycom a downloader for files
@Codemycom
3 жыл бұрын
@@dragoneater2008_ I don't have any videos on that
@dragoneater2008_
3 жыл бұрын
@@Codemycom can you make some tutorials?
@Codemycom
3 жыл бұрын
@@dragoneater2008_ no plans for that, sorry
Jai Shree Ram
@Codemycom
4 жыл бұрын
ok
Ничего не понятно, но очень интересно
@Codemycom
3 жыл бұрын
What about it do you find unclear?
@skyand_fly
3 жыл бұрын
@@Codemycom All clear! Thanks for the lessons! Previous post it was Russian sarcasm. Бессмысленный и беспощадный
Jai Shree Krishna
@Codemycom
4 жыл бұрын
why?
@rajmaddheshiya3025
4 жыл бұрын
@@Codemycom noting! Sir because you are best🙏🙏
100