Progress bars are used to offer user the visual sign of a long running process. The gtk.ProgressBar widget can be used in two modes — percentage mode and activity mode.
When it is likely to precisely guess how much of work is undecided to be finished, the progress bar can be used in percentage mode, and the user sees an incremental bar display percentage of completed job. If on the other hand, the amount of work to be completed can be precisely determined, the progress bar is used in activity mode in which, the bar shows the activity by displaying a block moving back and forth.
The resulting constructor initializes the widget of the gtk.ProgressBar class –
gtk.ProgressBar uses the resulting methods to manage functionality −
In the resulting program, the gtk.ProgressBar widget is used in activity mode. Therefore, the initial position of progress is set to 0.0 by the set_fraction()method.
In order to increment the progress by 1 percent after 100 milliseconds, a timer object is declared and a callback function is set up to be invoked after every 100 ms so that the progress bar is updated.
Now, progress_timeout() is the callback function. It increments the parameter of the set_fraction() method by 1 percent and updates the text in progress bar to show the percentage of completion.
Observe the resulting code –
The above code will generate the resulting output –
To use the progress bar in activity mode, change callback function to the resulting and run –
The back and forth movement of a block inside the Progress bar will show the progress of the activity.
PyGTK Related Interview Questions
|Python Interview Questions||PHP Interview Questions|
|Ruby on Rails Interview Questions||Ubuntu Certified Professional Interview Questions|
|Django Interview Questions||GNU Image Manipulation Program(GIMP) Interview Questions|
|TurboGears Interview Questions||Lisp programming Interview Questions|
|wxPython Interview Questions||Basic C Interview Questions|
|Python Automation Testing Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.