def restore_geometry(self): x = CONF.get("ManagerWindow", "x") y = CONF.get("ManagerWindow", "y") w = CONF.get("ManagerWindow", "width") h = CONF.get("ManagerWindow", "height") self.setGeometry(x, y, w, h)
def is_updated(): old_version = CONF.get("Version", "old_version") if old_version in [__version__, None]: return False else: CONF.set("Version", "old_version", __version__) return True
def on_plot_checkbox_toggeled(checked): CONF.set("ManagerWindow", "auto_plot_results", checked)
def save_geometry(self): geo = self.geometry() CONF.set("ManagerWindow", "height", geo.height()) CONF.set("ManagerWindow", "width", geo.width()) CONF.set("ManagerWindow", "x", geo.x()) CONF.set("ManagerWindow", "y", geo.y())
def __init__(self, manager): # noinspection PyArgumentList QtWidgets.QMainWindow.__init__(self) # get input arguments self.manager = manager self.job_queue = self.manager.job_queue self.result_queue = self.manager.result_queue # ============================================================================== # Set-up the UI # ============================================================================== uic.loadUi(os.path.join(_root, "manager_window.ui"), self) self.helpButton.clicked.connect(lambda: webbrowser.open_new(__url__)) # create about window and update window self.aboutWindow = AboutWindow() # load resources self.icon_queued = QtGui.QIcon(_root + "/resources/[email protected]") self.icon_running = QtGui.QIcon(_root + "/resources/[email protected]") self.icon_aborted = QtGui.QIcon(_root + "/resources/[email protected]") self.icon_failed = QtGui.QIcon(_root + "/resources/[email protected]") self.icon_finished = QtGui.QIcon(_root + "/resources/[email protected]") # restore last position and size self.restore_geometry() # ============================================================================== # Updated UI to reflect Manager status # ============================================================================== # check status of worker thread (Paused or Running) and adjust buttons self.check_paused() # get states of checkboxes, text edits, etc self.get_email_list() self.get_notification_level() self.plotCheckBox.setChecked(CONF.get("ManagerWindow", "auto_plot_results")) # create data models for message log, job queue and result queue self.messageLogModel = info_handler.model self.jobQueueModel = QtGui.QStandardItemModel(0, 2) self.resultQueueModel = QtGui.QStandardItemModel(0, 3) h0 = ["Function", "Arguments"] h1 = ["Type", "Size", "Value"] h2 = ["Time", "Level", "Message"] self.jobQueueModel.setHorizontalHeaderLabels(h0) self.resultQueueModel.setHorizontalHeaderLabels(h1) self.messageLogModel.setHorizontalHeaderLabels(h2) # add models to views self.jobQueueDisplay.setModel(self.jobQueueModel) self.resultQueueDisplay.setModel(self.resultQueueModel) self.messageLogDisplay.setModel(self.messageLogModel) # populate models with queue elements self.populate_results() self.populate_jobs() # set context menus for job_queue and result_queue items self.resultQueueDisplay.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.jobQueueDisplay.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) # ============================================================================== # Connect signals, slots, and callbacks # ============================================================================== # update views when items are added to or removed from queues self.result_queue.added_signal.connect(self.on_result_added) self.result_queue.removed_signal.connect(self.on_results_removed) self.job_queue.added_signal.connect(self.on_job_added) self.job_queue.removed_signal.connect(self.on_jobs_removed) self.job_queue.status_changed_signal.connect(self.on_job_status_changed) # perform various UI updates after status change status_handler.status_signal.connect(self.statusField.setText) status_handler.status_signal.connect(self.check_paused) status_handler.status_signal.connect(self.get_email_list) # notify user of any errors in job execution with a message box error_handler.error_signal.connect(self.show_error) # connect menu bar callbacks self.action_About.triggered.connect(self.aboutWindow.show) self.actionCustomXepr_Help.triggered.connect( lambda: webbrowser.open_new(__url__) ) self.actionShow_log_files.triggered.connect(self.on_log_clicked) self.action_Exit.triggered.connect(self.exit_) if not os.popen("Xepr --apipath").read() == "": url = "file://" + os.popen("Xepr --apipath").read() + "/docs/XeprAPI.html" self.actionXeprAPI_Help.triggered.connect(lambda: webbrowser.open_new(url)) else: self.actionXeprAPI_Help.setEnabled(False) # connect context menu callbacks self.resultQueueDisplay.customContextMenuRequested.connect( self.open_result_context_menu ) self.jobQueueDisplay.customContextMenuRequested.connect( self.open_job_context_menu ) # plot result on double click self.resultQueueDisplay.doubleClicked.connect(self.on_result_double_clicked) # connect job control buttons self.pauseButton.clicked.connect(self.on_pause_clicked) self.abortButton.clicked.connect(self.manager.abort_job) self.clearButton.clicked.connect(self.manager.clear_all_jobs) # connect log control settings self.lineEditEmailList.returnPressed.connect(self.set_email_list) self.bG.buttonClicked["int"].connect(self.on_bg_clicked) self.plotCheckBox.toggled.connect(self.on_plot_checkbox_toggeled) # Universal timeout: # Send an email notification if there is no status update for 30 min. _timeout_min = 30 self._min2msec = 60 * 1000 self.timeout_timer = QtCore.QTimer() self.timeout_timer.setInterval(_timeout_min * self._min2msec) self.timeout_timer.setSingleShot(True) self.timeout_timer.timeout.connect(self.timeout_warning) # reset timer when there is a status update status_handler.status_signal.connect(self.timeout_timer.start) # ============================================================================== # Inform user of changes # ============================================================================== if self.is_updated(): self.updateWindow = UpdateWindow() QtCore.QTimer.singleShot(5000, self.updateWindow.exec_)