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.

2Progress Bar
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
[11593]9completion of the task. The progress is then either on the icon
10of the widget in Orange Canvas
[11593]12.. image:: learningcurve.png
14or in the title bar of the widget's window. There, Orange also
15reports on the estimated time of completion of the task:
[11593]17.. image:: learningcurve-output.png
[11593]19:class:`OWWidget` has for this purpose a set of functions, which include:
[11408]21.. method:: progressBarInit()
23.. method:: progressBarSet(value)
25.. method:: progressBarFinished()
[11049]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
[11593]31:class:`ProgressBar` class in :mod:`OWGUI`, and the code in
[11049]32the learning curve widget described in the previous lesson that does
33it is as follows::
35    def getLearningCurve(self, learners):
[11593]36        pb = OWGUI.ProgressBar(self, iterations=self.steps * self.folds)
37        curve = Orange.evaluation.testing.learning_curve_n(
38            learners,, folds=self.folds,
39            proportions=self.curvePoints, callback=pb.advance)
[11049]40        pb.finish()
41        return curve
[11593]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.