Changeset 11592:53ab0451fc03 in orange


Ignore:
Timestamp:
06/11/13 12:33:03 (10 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added progress bar state tracking in OWBaseWidget.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/OWBaseWidget.py

    r11548 r11592  
    44# A General Orange Widget, from which all the Orange Widgets are derived 
    55# 
     6import warnings 
     7 
    68from Orange.utils import environ 
    79from Orange.orng.orngEnviron import directoryNames as old_directory_names 
     
    204206        self.__wasShown = False 
    205207        self.__progressBarValue = -1 
     208        self.__progressState = 0 
    206209 
    207210    # uncomment this when you need to see which events occured 
     
    729732        if self.progressBarHandler: 
    730733            self.progressBarHandler(self, 0) 
    731         self.processingStateChanged.emit(1) 
     734 
     735        if self.__progressState != 1: 
     736            self.__progressState = 1 
     737            self.processingStateChanged.emit(1) 
    732738 
    733739    def progressBarSet(self, value, processEventsFlags=QEventLoop.AllEvents): 
     
    740746        old = self.__progressBarValue 
    741747        if value > 0: 
     748            if self.__progressState != 1: 
     749                warnings.warn("progressBarSet() called without a " 
     750                              "preceding progressBarInit()", 
     751                              stacklevel=2) 
     752                self.__progressState = 1 
     753                self.processingStateChanged.emit(1) 
     754 
    742755            self.__progressBarValue = value 
    743756            usedTime = max(1, time.time() - self.startTime) 
     
    780793        if self.progressBarHandler: 
    781794            self.progressBarHandler(self, 101) 
    782         self.processingStateChanged.emit(0) 
     795 
     796        if self.__progressState != 0: 
     797            self.__progressState = 0 
     798            self.processingStateChanged.emit(0) 
    783799 
    784800    # handler must be a function, that receives 2 arguments. First is the widget instance, the second is the value between -1 and 101 
Note: See TracChangeset for help on using the changeset viewer.