Description
The gtk.ProgressBar
is typically used to display the progress of a long running operation. It
provides a visual clue that processing is underway. The gtk.ProgressBar
can be used in two different modes: percentage mode and activity
mode.
When an application can determine how much work needs to take
place (e.g. read a fixed number of bytes from a file) and can monitor its
progress, it can use the gtk.ProgressBar
in percentage mode and the user sees a growing bar indicating the percentage
of the work that has been completed. In this mode, the application is
required to call the set_fraction
()
method periodically to update the progress bar.
When an application has no accurate way of knowing the amount of
work to do, it can use the gtk.ProgressBar
in activity mode, which shows activity by a block moving back and forth
within the progress area. In this mode, the application is required to call
the pulse
()
method periodically to update the progress bar.
There is quite a bit of flexibility provided to control the
appearance of the gtk.ProgressBar
.
Methods are provided to control the orientation of the bar, optional text
can be displayed along with the bar, and the step size used in activity mode
can be set.
Methods
gtk.ProgressBar.pulse
def pulse()
The pulse
() method nudges the
progressbar to indicate that some progress has been made, but you don't know
how much. This method also changes progress bar mode to "activity mode,"
where a block bounces back and forth. Each call to the pulse
()
method causes the block to move by a little bit (the amount of movement per
pulse is determined by the set_pulse_step
()
method).
gtk.ProgressBar.set_text
def set_text(text
)
The set_text
() method superimposes the
text specified by text
on the progress bar.
gtk.ProgressBar.set_fraction
def set_fraction(fraction
)
fraction :
| the fraction of the task that's been
completed |
The set_fraction
() method causes the
progress bar to "fill in" the portion of the bar specified by
fraction
. The value of
fraction
should be between 0.0 and 1.0.
gtk.ProgressBar.set_pulse_step
def set_pulse_step(fraction
)
fraction :
| a value between 0.0 and
1.0 |
The set_pulse_step
() method sets the
portion (specified by fraction
) of the total progress
bar length to move the bouncing block for each call to the pulse
()
method.
gtk.ProgressBar.set_orientation
def set_orientation(orientation
)
orientation :
| the orientation of the progress
bar |
The set_orientation
() method switches
the progress bar to a different orientation as specified by the value of
orientation
. The value of
orientation
must be one of the GTK ProgressBar Orientation Constants.
gtk.ProgressBar.get_text
def get_text()
Returns : | the text, or
None |
The get_text
() method returns the text
superimposed on the progress bar. If there is no superimposed text this
method returns None
.
gtk.ProgressBar.get_fraction
def get_fraction()
Returns : | a fraction from 0.0 to 1.0 |
The get_fraction
() method returns the
current fraction of the task that's been set by the set_fraction
()
method .
gtk.ProgressBar.get_pulse_step
def get_pulse_step()
Returns : | a fraction from 0.0 to 1.0 |
The get_pulse_step
() method returns the
pulse step set with the set_pulse_step
().
gtk.ProgressBar.get_orientation
def get_orientation()
Returns : | the orientation of the progress
bar |
The get_orientation
() method returns
the current progress bar orientation. See the set_orientation
()
method for information about the orientation values.
gtk.ProgressBar.set_ellipsize
def set_ellipsize(mode
)
Note
This method is available in PyGTK 2.6 and above.
The set_ellipsize
() method sets the
mode used to ellipsize (add an ellipsis "...") the text if there is not
enough space to render the entire string to the value specified by
mode
. mode
must be one of the
Pango Ellipsize Mode Constants
gtk.ProgressBar.get_ellipsize
def get_ellipsize()
Returns : | the mode used to ellipsize
text |
Note
This method is available in PyGTK 2.6 and above.
The get_ellipsize
() method returns the
mode used to ellipsize text when there is not enough space. See the set_ellipsize
()
method for information.