def refuse_login(self, stat, message=None): if message is not None: if stat is False: icon = QtImport.QMessageBox.Critical elif stat is None: icon = QtImport.QMessageBox.Warning elif stat is True: icon = QtImport.QMessageBox.Information msg_dialog = QtImport.QMessageBox( "Register user", message, icon, QtImport.QMessageBox.Ok, QtImport.QMessageBox.NoButton, QtImport.QMessageBox.NoButton, self, ) s = self.font().pointSize() f = msg_dialog.font() f.setPointSize(s) msg_dialog.setFont(f) msg_dialog.updateGeometry() msg_dialog.show() self.setEnabled(True)
def set_ispyb_down(self): msg_dialog = QtImport.QMessageBox( "Register user", "Couldn't contact " + "the ISPyB database server: you've been logged as the local user.\n" + "Your experiments' information will not be stored in ISPyB!", QtImport.QMessageBox.Warning, QtImport.QMessageBox.Ok, QtImport.QMessageBox.NoButton, QtImport.QMessageBox.NoButton, self, ) s = self.font().pointSize() f = msg_dialog.font() f.setPointSize(s) msg_dialog.setFont(f) msg_dialog.updateGeometry() msg_dialog.show() now = time.strftime("%Y-%m-%d %H:%M:S") prop_dict = {"code": "", "number": "", "title": "", "proposalId": ""} ses_dict = { "sessionId": "", "startDate": now, "endDate": now, "comments": "" } self.accept_login(prop_dict, ses_dict)
def execute_tool(self): """Executes tool asigned to the menu action Asks for a confirmation if a tool has a conformation msg. """ for key in self.action_dict.keys(): if key == self.sender(): tool = self.action_dict[key] if tool.get("confirmation"): conf_dialog = QtImport.QMessageBox( QtImport.QMessageBox.Question, "Question", str(tool["confirmation"]), QtImport.QMessageBox.Ok | QtImport.QMessageBox.Cancel, ) rec = QtImport.QApplication.desktop().screenGeometry() pos_x = rec.right( ) + rec.width() / 2 - conf_dialog.width() / 2 pos_y = rec.height() / 2 conf_dialog.move(pos_x, pos_y) if conf_dialog.exec_() == QtImport.QMessageBox.Ok: getattr(tool["hwobj"], tool["method"])() else: getattr(tool["hwobj"], tool["method"])()