diff --git a/Orange/widgets/widget.py b/Orange/widgets/widget.py index 4b43996b0df..24c2bd5d765 100644 --- a/Orange/widgets/widget.py +++ b/Orange/widgets/widget.py @@ -7,7 +7,8 @@ from AnyQt.QtWidgets import ( QWidget, QDialog, QVBoxLayout, QSizePolicy, QApplication, QStyle, - QShortcut, QSplitter, QSplitterHandle, QPushButton, QStatusBar, QFrame + QShortcut, QSplitter, QSplitterHandle, QPushButton, QStatusBar, QFrame, + QProgressBar ) from AnyQt.QtCore import ( Qt, QByteArray, QSettings, QUrl, QSize, pyqtSignal as Signal @@ -347,8 +348,28 @@ def set_basic_layout(self): self.message_bar = MessagesWidget(self) self.message_bar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) + pb = QProgressBar(maximumWidth=120, minimum=0, maximum=100) + pb.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Ignored) + pb.setAttribute(Qt.WA_LayoutUsesWidgetRect) + pb.setAttribute(Qt.WA_MacMiniSize) + pb.hide() + sb.addPermanentWidget(pb) sb.addPermanentWidget(self.message_bar) + def statechenged(): + pb.setVisible(bool(self.processingState) or self.isBlocking()) + if self.isBlocking() and not self.processingState: + pb.setRange(0, 0) # indeterminate pb + elif self.processingState: + pb.setRange(0, 100) # determinate pb + + self.processingStateChanged.connect(statechenged) + self.blockingStateChanged.connect(statechenged) + + @self.progressBarValueChanged.connect + def _(val): + pb.setValue(int(val)) + def save_graph(self): """Save the graph with the name given in class attribute `graph_name`.