Progress bar Style


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


Style: 

 style= ttk.Style()
 style.theme_use('default')   style.configure('green.Horizonatal.TProgressbar',background='red'  
             

theme_use will be 'winnative','clam','alt',' default', 'classic', 'xpnative'.

Example: 

******Your code Below*****

from tkinter import *
from tkinter import ttk

root = Tk()
root.title("progress Bar")
root.geometry("900x400+380+86")

def start_progressbar():
your_progbar.start()

lbl =Label(root, text="Progress Bar",font=("Times",30,"bold"))
lbl.pack(pady=20)

style = ttk.Style()
style.theme_use('alt')
style.configure("green.Horizontal.TProgressbar",background='red')

your_progbar = ttk.Progressbar(root, orient=HORIZONTAL, length=600, mode="determinate",style="green.Horizontal.TProgressbar")
your_progbar.pack()

btn=Button(root, text="Start", font=("Times",25,"bold"),command=start_progressbar)
btn.pack(pady=20)

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


If You Want To Learn More Plz Visit www.newpost24.com







Post a Comment

Previous Post Next Post