Changeset 11482:30188643fe5b in orange


Ignore:
Timestamp:
04/30/13 10:56:21 (12 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added 'progressEventsFlags' argument to 'progressBarSet' method.

Location:
Orange
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/orngView.py

    r10733 r11482  
    413413            if widget.instance == widgetInstance: 
    414414                widget.setProgressBarValue(value) 
    415                 qApp.processEvents()        # allow processing of other events 
    416415                return 
    417416 
  • Orange/OrangeWidgets/OWBaseWidget.py

    r11481 r11482  
    202202        self.asyncCalls = [] 
    203203        self.asyncBlock = False 
     204        self.__progressBarValue = -1 
    204205 
    205206    # uncomment this when you need to see which events occured 
     
    745746        self.processingStateChanged.emit(1) 
    746747 
    747     def progressBarSet(self, value): 
     748    def progressBarSet(self, value, processEventsFlags=QEventLoop.AllEvents): 
     749        """ 
     750        Set the current progress bar to `value`. This method will also call 
     751        `qApp.processEvents` with the `processEventsFlags` unless the 
     752        processEventsFlags equals ``None``. 
     753 
     754        """ 
     755        old = self.__progressBarValue 
    748756        if value > 0: 
    749757            self.__progressBarValue = value 
     
    764772            self.progressBarHandler(self, value) 
    765773 
    766         self.progressBarValueChanged.emit(value) 
    767  
    768         qApp.processEvents() 
     774        if old != value: 
     775            self.progressBarValueChanged.emit(value) 
     776 
     777        if processEventsFlags is not None: 
     778            qApp.processEvents(processEventsFlags) 
    769779 
    770780    def progressBarValue(self): 
    771781        return self.__progressBarValue 
    772782 
    773     progressBarValue = pyqtProperty(float, fset=progressBarSet, 
    774                                     fget=progressBarValue) 
    775  
    776     def progressBarAdvance(self, value): 
    777         self.progressBarSet(self.progressBarValue + value) 
     783    progressBarValue = pyqtProperty( 
     784        float, 
     785        fset=lambda self, val: 
     786            self.progressBarSet(val, processEventsFlags=None), 
     787        fget=progressBarValue 
     788    ) 
     789 
     790    def progressBarAdvance(self, value, processEventsFlags=QEventLoop.AllEvents): 
     791        self.progressBarSet(self.progressBarValue + value, processEventsFlags) 
    778792 
    779793    def progressBarFinished(self): 
Note: See TracChangeset for help on using the changeset viewer.