Python tkinter Progressbar
« Basics of Python Tkinter
We can display status of any process by using Progressbar which is part of ttk module.
Tkinter Progressbar to show status with options and methods to manage and display values
VIDEO
Code for a basic Progressbar is here.
import tkinter as tk
from tkinter import *
from tkinter import ttk
my_w = tk.Tk()
my_w.geometry("400x200")
prg1 = ttk.Progressbar(my_w,orient = HORIZONTAL,
value=70,length = 300, mode = 'determinate')
prg1.place(relx=.1,rely=.2)
my_w.mainloop() # Keep the window open
Progressbar Options
Options Details
orient Orientation of the Progress bar. Values are Horizontal or Vertical
length Length of the Progress bar, (width if horizontal, height if vertical)
mode Values can be determinate OR indeterminate Check the examples
maximum Default value is 100, specifies the maximum value.
value The current value of the Progress bar. Can be set or read.
variable Variable can be linked to value of Progress Bar. Realtime changes ( in values ) can be captured.
Options : value, mode ,orient ,variable etc.. →
Progressbar Methods
Method Details
start( interval ) increment the Progress bar in every interval value (50 milliseconds default )
step( amount ) Default is 1 if omitted, increments in the progress bar value by given amount
stop() Stop the autoincrement mode.
start() step() and stop() Method example →
Getting values of all options of Progress bar
We will get a dictionary and by using the keys we can get the set values of the options of the Progress bar.
Here we can set the values of the options also.
my_dict=ttk.Progressbar(prg1)
print(my_dict['orient']) # print the value of orient
print(my_dict['mode']) # value of mode
Number of tasks completed
While participating in any online survey you can see one progress bar reflecting the number of questions completed and number of questions balance.
Create one window with six pair of radio buttons where user has to select one choice for each question.
The progress bar will show the progress based on number of Choices made.
Showing progress status based on Selection of Radio buttons→
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com
Python programming Basics ⇩