Progress bar Using Function
Progress bar widget
allows you to give feedback to the user about the progress of a
long-running task. The purpose of this widget is to reassure the user
that something is happening.
-->used in loading or downloading types of process.
-->useful to display the status of an operation or task.
-->can indicate the evolution of a certain process(example downloading a file from the Internet).
-->represent that an operation is being executed. Remaining time is unknown.
The progress bar executes in two modes:-
1) Determinate mode
2) Indeterminate mode
Determinate mode
In the determinate mode, the progress bar shows
an indicator from the beginning to the end of the widget. If you know
how to measure relative progress, you can use the determinate mode.
Indeterminate mode:
In the indeterminate mode, the progress bar shows
an indicator that bounces back and forth between the ends of the
widget. you use the indeterminate mode when you don’t know how to
accurately measure the time that the long-running task takes to
complete.
Syntax: Progressbar(container, orient, length, mode)
-->container is parent component of the progress bar.
-->orient can be either 'horizontal' or 'vertical'.
-->length represents the width of a horizontal progress bar
or height of a vertical progress bar.
-->The mode can be either 'determinate' or 'indeterminate'.
Example:
******Your code Below*****
from tkinter import *
from tkinter import ttk
root = Tk()
root.title("Progress Bar Start/Stop Determinate Mode")
root.config(background="#FFF8DC")
root.geometry("600x360+400+50")
def start():
my_progress.start()
def stop():
my_progress.stop()
def step():
my_progress.start()
my_progress.step(20)
lbl= Label(root,text="Progress Bar",font=("Times", 30, "bold"))
lbl.pack(pady=10)
my_progress = ttk.Progressbar(root, orient=HORIZONTAL,length=500, mode='determinate',)
my_progress.pack(pady=10)
btn_start = Button(root, text="Progressbar Start",font=('times',20,'bold'), command=start)
btn_start.pack(pady=10)
btn_step = Button(root, text="Progressbar Step",font=('times',20,'bold'), command=step)
btn_step.pack(pady=10)
btn_stop = Button(root, text="Progressbar Stop",font=('times',20,'bold'), command=stop)
btn_stop.pack(pady=10)
root.mainloop()
********End Code**********
Write Down Code Your Code Editor. To show Your Output. If Use Pycharm Press Shift+F10 and Show Your Output.
Enjoy........
إرسال تعليق