source: orange/docs/extend-widgets/rst/progressbar.rst @ 11593:6edc44eb9655

Revision 11593:6edc44eb9655, 1.7 KB checked in by Ales Erjavec <ales.erjavec@…>, 10 months ago (diff)

Updated Widget development tutorial.

Line 
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 on the icon
10of the widget in Orange Canvas
11
12.. image:: learningcurve.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:: learningcurve-output.png
18
19:class:`OWWidget` has for this purpose a set of functions, which include:
20
21.. method:: progressBarInit()
22
23.. method:: progressBarSet(value)
24
25.. method:: progressBarFinished()
26
27where value is any number between 0 and 100. Sometimes, like it is
28the case for our widgets, we know about the number of iterations involved in
29computation, and we would only like to advance the progress bar for
30some constant at the end of the iteration. For this, we use
31:class:`ProgressBar` class in :mod:`OWGUI`, and the code in
32the learning curve widget described in the previous lesson that does
33it is as follows::
34
35    def getLearningCurve(self, learners):
36        pb = OWGUI.ProgressBar(self, iterations=self.steps * self.folds)
37        curve = Orange.evaluation.testing.learning_curve_n(
38            learners, self.data, folds=self.folds,
39            proportions=self.curvePoints, callback=pb.advance)
40        pb.finish()
41        return curve
42
43:class:`ProgressBar` class removes the need to define any special
44function to compute the percent of the task done and set the
45progress bar, and instead uses :class:`ProgressBar`'s method
46:func:`advance` for this purpose.
Note: See TracBrowser for help on using the repository browser.