Movatterモバイル変換


[0]ホーム

URL:


Open In App
Next Article:
Python Tkinter - Create Button Widget
Next article icon
The purpose of this widget is to reassure the user that something is happening. It can operate in one of two modes -Indeterminate mode, the widget shows an indicator that moves from beginning to end under program control.Inindeterminate mode, the widget is animated so the user will believe that something is in progress. In this mode, the indicator bounces back and forth between the ends of the widget.Syntax:
widget_object = Progressbar(parent, **options)
 Code #1 Indeterminate modePython3 1==
# importing tkinter modulefromtkinterimport*fromtkinter.ttkimport*# creating tkinter windowroot=Tk()# Progress bar widgetprogress=Progressbar(root,orient=HORIZONTAL,length=100,mode='determinate')# Function responsible for the updation# of the progress bar valuedefbar():importtimeprogress['value']=20root.update_idletasks()time.sleep(1)progress['value']=40root.update_idletasks()time.sleep(1)progress['value']=50root.update_idletasks()time.sleep(1)progress['value']=60root.update_idletasks()time.sleep(1)progress['value']=80root.update_idletasks()time.sleep(1)progress['value']=100progress.pack(pady=10)# This button will initialize# the progress barButton(root,text='Start',command=bar).pack(pady=10)# infinite loopmainloop()
Output:
 Code #2: Inindeterminate modePython3 1==
# importing tkinter modulefromtkinterimport*fromtkinter.ttkimport*# creating tkinter windowroot=Tk()# Progress bar widgetprogress=Progressbar(root,orient=HORIZONTAL,length=100,mode='indeterminate')# Function responsible for the updation# of the progress bar valuedefbar():importtimeprogress['value']=20root.update_idletasks()time.sleep(0.5)progress['value']=40root.update_idletasks()time.sleep(0.5)progress['value']=50root.update_idletasks()time.sleep(0.5)progress['value']=60root.update_idletasks()time.sleep(0.5)progress['value']=80root.update_idletasks()time.sleep(0.5)progress['value']=100root.update_idletasks()time.sleep(0.5)progress['value']=80root.update_idletasks()time.sleep(0.5)progress['value']=60root.update_idletasks()time.sleep(0.5)progress['value']=50root.update_idletasks()time.sleep(0.5)progress['value']=40root.update_idletasks()time.sleep(0.5)progress['value']=20root.update_idletasks()time.sleep(0.5)progress['value']=0progress.pack(pady=10)# This button will initialize# the progress barButton(root,text='Start',command=bar).pack(pady=10)# infinite loopmainloop()
Output:

Similar Reads

We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood ourCookie Policy &Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp