Skip to content

Commit

Permalink
OWWidget: Progress bar widget in the status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Jul 11, 2017
1 parent b753748 commit 98c6523
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion Orange/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`.
Expand Down

0 comments on commit 98c6523

Please sign in to comment.