def updateshows(self): ''' Update local shows with remote content ''' label = QLabel('Updating: ') bar = QProgressBar() bar.setMinimum(0) bar.setMaximum(self.ui.showlist.model().rowCount()) bar.setValue(bar.minimum()) self.ui.statusbar.addWidget(label) self.ui.statusbar.addWidget(bar) for row in range(self.ui.showlist.model().rowCount()): self.backend.updateshow(self.ui.showlist.model().getshow(row).id) bar.setValue(row) self.ui.statusbar.removeWidget(bar) self.ui.statusbar.removeWidget(label) now = datetime.now() self.settings.set(settings.categories.application, settings.keys.lastupdated, now) self.setlastupdatedstatus(now) self.displayshowstatuses()
def displayshowstatuses(self): ''' Set the show statuses for all shows This only really needs to be done at the start or after updating data ''' label = QLabel('Updating status: ') self.ui.statusbar.addWidget(label) shows = self.backend.getlocalshows() showbar = QProgressBar() showbar.setMinimum(0) showbar.setMaximum(len(shows)) showbar.setValue(showbar.minimum()) self.ui.statusbar.addWidget(showbar) for show in shows: self.displayshowstatus(show.id) showbar.setValue(shows.index(show) + 1) self.ui.statusbar.removeWidget(showbar) self.ui.statusbar.removeWidget(label)
class MessageDialog(QWidget): def __init__(self, mailList, jobID = '', sec = 0, parent = None): QWidget.__init__(self, parent) self.prnt = parent self.jobID = jobID self.sec = sec self.frozen = False self.tr = self.prnt.prnt.tr self.setWindowTitle(self.tr._translate('M@il Checker : MailView Dialog')) self.setStyleSheet("QWidget {background: rgba(235,240,255,128);}") self.mailList = QLabel(mailList) self.layout = QVBoxLayout() self.buttonLayout = QHBoxLayout() self.ok = QPushButton(QIcon.fromTheme("dialog-ok"), "", self) self.cancel = QPushButton(QIcon.fromTheme("dialog-cancel"), "", self) self.freezMSG = QPushButton(QIcon.fromTheme("layer-visible-on"), '', self) self.freezMSG.setToolTip(self.tr._translate('Freez message')) self.ok.setMaximumHeight(15) self.freezMSG.setMaximumHeight(15) self.cancel.setMaximumHeight(15) self.ok.clicked.connect(self.accepted) self.freezMSG.clicked.connect(self.freez) self.cancel.clicked.connect(self.rejected) self.buttonLayout.addWidget(self.ok) self.buttonLayout.addWidget(self.freezMSG) self.buttonLayout.addWidget(self.cancel) self.layout.addWidget(self.mailList) if sec : self.lifetime = QProgressBar() self.lifetime.setOrientation(Qt.Horizontal) self.lifetime.setMinimum(0) self.lifetime.setMaximum(sec) self.lifetime.setValue(sec) self.lifetime.setMaximumHeight(7) self.layout.addWidget(self.lifetime) self.lifetimeID = self.startTimer(1000) self.layout.addItem(self.buttonLayout) self.setLayout(self.layout) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setMinimumWidth(100) def accepted(self): self.prnt.prnt.viewJob.emit(self.jobID) if self.prnt.prnt.SoundEnabled : self.prnt.prnt.sound.Accepted.play() self.close() def rejected(self, common = False): if self.prnt.prnt.SoundEnabled and not common : self.prnt.prnt.sound.Cleared.play() self.close() def freez(self, common = False): if self.sec : self.killTimer(self.lifetimeID) self.setStyleSheet("QWidget {background: rgba(100,175,255,25);}") self.frozen = True self.freezMSG.setEnabled(False) if self.prnt.prnt.SoundEnabled and not common : self.prnt.prnt.sound.Frozen.play() def timerEvent(self, ev): if ev.type()==QEvent.Timer : value = self.lifetime.value() #print ev.timerId(), value if value > self.lifetime.minimum() : self.lifetime.setValue(value-1) else : self.close() def isFrozen(self): return self.frozen def closeEvent(self, ev): if ev.type()==QEvent.Close : if self.sec : self.killTimer(self.lifetimeID) self.prnt.checkEmpty.emit(self.jobID) self.prnt.prnt.clearJob.emit(self.jobID) ev.accept() else : ev.ignore()
class dialog_auto_prog(QDialog): #----------------------------------------------------------------------- # DEFINE THE INITIALIZATION FUNCTION. #----------------------------------------------------------------------- def __init__(self, time_strt, time_stop): # Inherit all attributes of an instance of "QDialog". super(dialog_auto_prog, self).__init__() # Make this a non-modal dialog (i.e., allow the user to still # interact with the main application window). self.setModal(False) # Set the title of this dialog window. self.setWindowTitle('Progress') # Give this widget a grid layout, "self.grd". self.grd = QGridLayout() self.grd.setContentsMargins(6, 6, 6, 6) self.setLayout(self.grd) # Initialize the progress bar and set its minimum, maximum, and # initial values. self.bar = QProgressBar() self.bar.setMinimum(calc_time_val(time_strt)) self.bar.setMaximum(calc_time_val(time_stop)) self.bar.setValue(self.bar.minimum()) # Initialize the event button. self.btn_exit = event_PushButton(self, 'exit', 'Close') # Initialize the label. self.lab = QLabel('Note: closing this window will *NOT* ' + 'interrupt the automated analysis.') self.lab.setWordWrap(True) # Row by row, add the bar and buttons to the grid layout. self.grd.addWidget(self.bar, 0, 0, 1, 1) self.grd.addWidget(self.btn_exit, 0, 1, 1, 1) self.grd.addWidget(self.lab, 1, 0, 1, 2) # Display this dialog. self.show() #----------------------------------------------------------------------- # DEFINE THE FUNCTION FOR UPDATING THE PROGRESS BAR. #----------------------------------------------------------------------- def updt_bar(self, time): # Convert this functions argument (i.e., the timestamp of the # current spectrum) to Unix time. time_curr = calc_time_val(time) # If necessary, adjust the minimum or maximum of the progress # bar based on the new timestamp. if (time_curr < self.bar.minimum()): self.bar.setMinimum(time_curr) if (time_curr > self.bar.maximum()): self.bar.setMaximum(time_curr) # Update the value of the progress bar. self.bar.setValue(time_curr) #----------------------------------------------------------------------- # DEFINE THE FUNCTION FOR RESPONDING TO A USER-INITIATED EVENT. #----------------------------------------------------------------------- def user_event(self, event, fnc): # If the close button was pressed, close this dialog. if (fnc == 'exit'): self.close() return