| 1 |
.. currentmodule:: gi.repository |
| 2 |
|
| 3 |
ProgressBar |
| 4 |
=========== |
| 5 |
The :class:`Gtk.ProgressBar` is typically used to display the progress of a |
| 6 |
long running operation. It provides a visual clue that processing is underway. |
| 7 |
The :class:`Gtk.ProgressBar` can be used in two different modes: *percentage |
| 8 |
mode* and *activity mode*. |
| 9 |
|
| 10 |
When an application can determine how much work needs to take place (e.g. read |
| 11 |
a fixed number of bytes from a file) and can monitor its progress, it can use |
| 12 |
the :class:`Gtk.ProgressBar` in *percentage mode* and the user sees a growing |
| 13 |
bar indicating the percentage of the work that has been completed. |
| 14 |
In this mode, the application is required to set |
| 15 |
:attr:`Gtk.ProgressBar.props.fraction` periodically to update the progress bar, |
| 16 |
setting a float between 0 and 1 to provide the new percentage value. |
| 17 |
|
| 18 |
When an application has no accurate way of knowing the amount of work to do, it |
| 19 |
can use *activity mode*, which shows activity by a block moving back and forth |
| 20 |
within the progress area. In this mode, the application is required to call |
| 21 |
:meth:`Gtk.ProgressBar.pulse` periodically to update the progress bar. |
| 22 |
You can also choose the step size, with the |
| 23 |
:attr:`Gtk.ProgressBar.props.pulse_step` property. |
| 24 |
|
| 25 |
By default, :class:`Gtk.ProgressBar` is horizontal and left-to-right, but you |
| 26 |
can change it to a vertical progress bar by changing the value of |
| 27 |
:attr:`Gtk.ProgressBar.props.orientation <Gtk.Orientable.props.orientation>`. |
| 28 |
Changing the direction the progress bar grows can be done using |
| 29 |
:attr:`Gtk.ProgressBar.props.inverted`. :class:`Gtk.ProgressBar` can also |
| 30 |
contain text which can be set with :attr:`Gtk.ProgressBar.props.text` and |
| 31 |
:attr:`Gtk.ProgressBar.props.show_text`. |
| 32 |
|
| 33 |
Example |
| 34 |
------- |
| 35 |
|
| 36 |
.. image:: images/progressbar.png |
| 37 |
|
| 38 |
.. literalinclude:: examples/progressbar.py |
| 39 |
:linenos: |