Sun, 30 Jan 2011 19:19:40 +0100
Made the code PEP-8 compliant.
# -*- coding: utf-8 -*- # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> # """ Module implementing a TaskHandle class with a progress dialog. """ from PyQt4.QtGui import QApplication, QProgressDialog, QLabel import rope.base.taskhandle class ProgressHandle(rope.base.taskhandle.TaskHandle): """ Class implementing TaskHandle with a progress dialog. """ def __init__(self, title, interruptable=True, parent=None): """ Constructor @param title title for the taskhandle (string) @param interruptable flag indicating, that the task may be interrupted (boolean) @param parent reference to the parent widget (QWidget) """ rope.base.taskhandle.TaskHandle.__init__(self, title, interruptable) if interruptable: cancelLabel = QApplication.translate("ProgressHandle", "Interrupt") else: cancelLabel = "" self.__progress = QProgressDialog("", cancelLabel, 0, 100, parent) label = QLabel("") label.setWordWrap(True) self.__progress.setLabel(label) self.add_observer(self.__updateProgress) def __updateProgress(self): """ Private slot to handle the task progress. """ jobset = self.current_jobset() if jobset: text = '' if jobset.get_name() is not None: text += jobset.get_name() if jobset.get_active_job_name() is not None: text += ' : ' + jobset.get_active_job_name() self.__progress.setLabelText(text) percent = jobset.get_percent_done() if percent is not None: self.__progress.setValue(percent) QApplication.processEvents() if not self.is_stopped() and self.__progress.wasCanceled(): self.stop() def show(self): """ Public slot to show the progress dialog. """ self.__progress.show() def reset(self): """ Public slot to reset the progress dialog. """ self.__progress.reset()