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

  • @Codemycom
    @Codemycom4 жыл бұрын

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

    @techdiyer5290

    3 жыл бұрын

    thanks :)

  • @pramilamenon8621

    @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

    @Codemycom

    2 жыл бұрын

    @@pramilamenon8621 Use a style element. Google tkinter style

  • @francescamiddleton8854
    @francescamiddleton88543 жыл бұрын

    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_

    @dragoneater2008_

    3 жыл бұрын

    I was looking for this too!

  • @manuelbenito1700
    @manuelbenito17003 жыл бұрын

    Thanks sir, this will be helpful for a little project I have. Really easy to understand!

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Glad it was helpful!

  • @Anish_88
    @Anish_884 жыл бұрын

    😍😍😍 I love it Thank you so much Mr. Elder

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    You are very welcome

  • @markfahey3023
    @markfahey30233 жыл бұрын

    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.

  • @lasindukashmira7272
    @lasindukashmira72724 жыл бұрын

    Thank you sir You are the best i learnt lot of things from you.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad to hear that!

  • @py_tok5589
    @py_tok55893 жыл бұрын

    nice tutorial, thank you Prof John

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    You are welcome

  • @eesakamaldien1917
    @eesakamaldien19172 жыл бұрын

    your videos are the best

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Thank you!

  • @RyanDanielG
    @RyanDanielG2 жыл бұрын

    Hit that like button Python Fans! Great tutorial. Feed the Algorithm!

  • @safwankhan199
    @safwankhan199 Жыл бұрын

    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

  • @aaroncatolico7550
    @aaroncatolico7550 Жыл бұрын

    Dammit! I broke the LIKE 👍🏻 button! I "SMASHED!" the like button too hard because of you, John!

  • @Codemycom

    @Codemycom

    Жыл бұрын

    Perfect! lol

  • @emperorj4783
    @emperorj47833 жыл бұрын

    This video needs more likes than it has

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    I agree, tell your friends!

  • @sidhumm
    @sidhumm4 жыл бұрын

    Thanks a lot again!!

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Thanks again for watching!

  • @sidhumm

    @sidhumm

    4 жыл бұрын

    You are the Best!!

  • @kapibara2440
    @kapibara2440Ай бұрын

    Thank you 😊

  • @Codemycom

    @Codemycom

    Ай бұрын

    You're welcome 😊

  • @nikolacesarovic
    @nikolacesarovic2 жыл бұрын

    Thank you sir

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    Welcome

  • @dukescompany7855
    @dukescompany78554 жыл бұрын

    Vídeo Muito bom, vou usar essa barra de progresso para questinarios ou mesmo como tela de login

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad you found it useful!

  • @aumpauskar4653
    @aumpauskar46533 жыл бұрын

    Really loved the tutorial but can you change the colour of the progress bar?

  • @klejdixheko3131
    @klejdixheko31314 жыл бұрын

    The video is amaizing nice thnx

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Glad you liked it

  • @parkerlumkes8686
    @parkerlumkes86864 жыл бұрын

    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

    @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

    @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.

  • @bricklee4744
    @bricklee47442 жыл бұрын

    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

    @Codemycom

    2 жыл бұрын

    Yeah never pack a thing on the same line that you define it.

  • @kwilla2001
    @kwilla20014 жыл бұрын

    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

    @Codemycom

    4 жыл бұрын

    Sorry, no..I don't know what gTTS does...

  • @kwilla2001

    @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.

  • @akramelomrani8728
    @akramelomrani87283 жыл бұрын

    Can we change the color of the Progressbar ?

  • @Surferdudeoh
    @Surferdudeoh3 жыл бұрын

    i conclude that when i import "ttk" the appearance of button also changes. : \

  • @aydenshahraki1084
    @aydenshahraki10843 жыл бұрын

    How can I use if statements with the progress bars?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Any way you want...I have more videos using them in the playlist I think...

  • @jonathan19910728
    @jonathan199107282 жыл бұрын

    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

    @Codemycom

    2 жыл бұрын

    Sorry, I don't know what you're referring to.

  • @harshvardhansinghchauhan231
    @harshvardhansinghchauhan2314 жыл бұрын

    Can we make a root window in which there is no title bar as we can create with c#

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    maybe

  • @Tijan1
    @Tijan14 жыл бұрын

    👍👍👍

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Thanks!

  • @pixel3616
    @pixel36163 жыл бұрын

    sir, how to change color of progress bar

  • @sreecharan4300
    @sreecharan43004 жыл бұрын

    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

    @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

    @Codemycom

    4 жыл бұрын

    Sorry I've never seen that, not sure how to fix it

  • @GameplayAce
    @GameplayAce Жыл бұрын

    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

    @Codemycom

    Жыл бұрын

    set the maximum to 1500. The video shows you how to add 15 to the bar.

  • @Aartiarora1230
    @Aartiarora12304 жыл бұрын

    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

    @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

    @bhavyagosai6712

    3 жыл бұрын

    Check out the Threading concept kzread.info/dash/bejne/nKKmpdJ6YduwgLQ.html&ab_channel=Codemy.com

  • @cmputerprgrammer7800
    @cmputerprgrammer78003 жыл бұрын

    Sir, how to make entry fields rounded with tkinter?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    No real easy way to do that, as far as I know

  • @ragheedmaloyan3730
    @ragheedmaloyan37303 жыл бұрын

    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

    @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

    @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

    @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

    @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 :)

  • @devenjain7116
    @devenjain71163 жыл бұрын

    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

    @Codemycom

    3 жыл бұрын

    Of course

  • @dimitardimitrov8002

    @dimitardimitrov8002

    2 жыл бұрын

    @@Codemycom Could you share a link for how it's done

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    @@dimitardimitrov8002 I have lots of videos on the playlist on binding things, look around

  • @MiguelRodriguez-fu7oi
    @MiguelRodriguez-fu7oi3 жыл бұрын

    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)

  • @wellitsasecret6547
    @wellitsasecret65473 жыл бұрын

    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

    @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

    @wellitsasecret6547

    3 жыл бұрын

    @@Codemycom Thanks for getting to me so fast! I will try this now :)

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    @@wellitsasecret6547 Good luck, I'm not sure it will work :-p

  • @wellitsasecret6547

    @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

    @Codemycom

    3 жыл бұрын

    @@wellitsasecret6547 Nice!

  • @alwynjoby9604
    @alwynjoby96043 жыл бұрын

    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

    @Codemycom

    3 жыл бұрын

    you have a typo somewhere

  • @ij1316

    @ij1316

    3 жыл бұрын

    It's a lowercase 'b' in Progressbar

  • @ntcellulartutorials1195
    @ntcellulartutorials11954 жыл бұрын

    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

    @Codemycom

    4 жыл бұрын

    Sorry, I don't know what you mean

  • @ntcellulartutorials1195

    @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

    @ntcellulartutorials1195

    4 жыл бұрын

    @@cool-cloud thank you very much I am going to do try that in my project

  • @freekeys
    @freekeys4 жыл бұрын

    Can we notify the user when new blog posted (web push notifications)? If yes pls make video on that.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    I think you maybe posted this comment under the wrong video

  • @freekeys

    @freekeys

    4 жыл бұрын

    @@Codemycom i know but I can't wait for right video so i commented just to give u a msg of that😅😂

  • @IQUBE
    @IQUBE4 жыл бұрын

    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

    @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

    @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

    @IQUBE

    4 жыл бұрын

    @@Codemycom Yeah the progress bar's name is progress. Anyway nice video

  • @IQUBE

    @IQUBE

    4 жыл бұрын

    @@garrybeck216 Nope. I double checked the code.

  • @akarshgupta2586

    @akarshgupta2586

    3 жыл бұрын

    does your code ever produce the value 100?

  • @AaryanGamer
    @AaryanGamer4 жыл бұрын

    Is there any way to use OOP with Tkinter?

  • @garrybeck216

    @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

    @Codemycom

    4 жыл бұрын

    Sure

  • @mohitsinghtangariya8842
    @mohitsinghtangariya88423 жыл бұрын

    can you please help me with a programme

  • @TipsTricksSolutions
    @TipsTricksSolutions2 жыл бұрын

    Is there a way to connect this progress bar with the pytube progress bar?

  • @Codemycom

    @Codemycom

    2 жыл бұрын

    I don't know what pytube is

  • @derpiesaurus

    @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

    @TipsTricksSolutions

    2 жыл бұрын

    @@derpiesaurus Oh thank you I will try it tomorrow..

  • @Not_A_Lazy_Dev
    @Not_A_Lazy_Dev Жыл бұрын

    thx bro i needed the root.update_idletasks() thingy

  • @mosoliman7992
    @mosoliman7992 Жыл бұрын

    watching this video solved my issue of my function not displaying whats happening as its doing it

  • @Codemycom

    @Codemycom

    Жыл бұрын

    Glad to hear it!

  • @kanwaradnan4849
    @kanwaradnan48493 жыл бұрын

    When i press start button I'm unable to use any other widget of app. How can i solve this??

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    use threading

  • @kanwaradnan4849

    @kanwaradnan4849

    3 жыл бұрын

    @@Codemycom yes I watched you're video of threading.. It solved my problem .. Thanks a lot

  • @pverprogramz641
    @pverprogramz6414 жыл бұрын

    Sir, can you lease make a video on ttk theming ?.

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    Yeah I might do that eventually

  • @ClusterSeries

    @ClusterSeries

    4 жыл бұрын

    @@Codemycom Sir, Is it possible to modify an existing ttk theme ?

  • @adarshs7982
    @adarshs79823 жыл бұрын

    I couldn't assign to progress['value'] shows as none type

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Did you pack and assign your widget on the same line? You can't do that

  • @adarshs7982

    @adarshs7982

    3 жыл бұрын

    Ok thanks

  • @beezeruk1
    @beezeruk14 жыл бұрын

    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

  • @danielrooney9945
    @danielrooney99453 жыл бұрын

    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

    @Codemycom

    3 жыл бұрын

    tkinter needs to be lowercase

  • @danielrooney9945

    @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

    @Codemycom

    3 жыл бұрын

    @@danielrooney9945 no sorry that's just not right... are you using different tools than me or something?

  • @dragoneater2008_
    @dragoneater2008_3 жыл бұрын

    How do I make a python tkinter downloader with a progress bar?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    Downloader of what?

  • @dragoneater2008_

    @dragoneater2008_

    3 жыл бұрын

    @@Codemycom a downloader for files

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    @@dragoneater2008_ I don't have any videos on that

  • @dragoneater2008_

    @dragoneater2008_

    3 жыл бұрын

    @@Codemycom can you make some tutorials?

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    @@dragoneater2008_ no plans for that, sorry

  • @rajmaddheshiya3025
    @rajmaddheshiya30254 жыл бұрын

    Jai Shree Ram

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    ok

  • @skyand_fly
    @skyand_fly4 жыл бұрын

    Ничего не понятно, но очень интересно

  • @Codemycom

    @Codemycom

    3 жыл бұрын

    What about it do you find unclear?

  • @skyand_fly

    @skyand_fly

    3 жыл бұрын

    @@Codemycom All clear! Thanks for the lessons! Previous post it was Russian sarcasm. Бессмысленный и беспощадный

  • @rajmaddheshiya3025
    @rajmaddheshiya30254 жыл бұрын

    Jai Shree Krishna

  • @Codemycom

    @Codemycom

    4 жыл бұрын

    why?

  • @rajmaddheshiya3025

    @rajmaddheshiya3025

    4 жыл бұрын

    @@Codemycom noting! Sir because you are best🙏🙏

  • @grmmth3
    @grmmth33 жыл бұрын

    100