source: orange/docs/extend-widgets/rst/progressbar.rst @ 11408:c2d2400b6a90

Revision 11408:c2d2400b6a90, 1.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 13 months ago (diff)

Fixes for Widgets Development documentation.

RevLine 
[11049]1************
2Progress Bar
3************
4
5Widgets, where there is any chance that their operation can be
6slower than split second, should report on the progress of their
7computation. For that purpose orange widgets use progress bar
8functions, to which they report progress in terms of per-cent
9completion of the task. The progress is then either reported above the
10icon of the widget in Orange Canvas.
11
12.. image:: progressbar-canvas.png
13
14or in the title bar of the widget's window. There, Orange also
15reports on the estimated time of completion of the task:
16
17.. image:: progressbar-widget.png
18
19Class :obj:`OWWidget`, the mother class of all
20widgets, has for this purpose a set of functions, which include:
21
[11408]22.. method:: progressBarInit()
23
24.. method:: progressBarSet(value)
25
26.. method:: progressBarFinished()
27
[11049]28
29where value is any number between 0 and 100. Sometimes, like it is
30the case for our widgets, we know about the number of iterations involved in
31computation, and we would only like to advance the progress bar for
32some constant at the end of the iteration. For this, we use
33:obj:`ProgressBar` class in :obj:`OWGUI`, and the code in
34the learning curve widget described in the previous lesson that does
35it is as follows::
36
37    def getLearningCurve(self, learners):
38        pb = OWGUI.ProgressBar(self, iterations=self.steps*self.folds)
39        curve = orngTest.learningCurveN(learners, self.data,
40            folds=self.folds, proportions=self.curvePoints, callback=pb.advance)
41        pb.finish()
42        return curve
43
44:obj:`ProgressBar` class removes the need to define any
45special function to compute the percent of the task done and set the
46progress bar, and instead uses :obj:`ProgressBar`'s method
47:obj:`advance` for this purpose.
Note: See TracBrowser for help on using the repository browser.