def start_gui(self, args): crypt_key = args.encryption if crypt_key is None: input_dialog = QInputDialog() input_dialog.setInputMode(QInputDialog.TextInput) input_dialog.setCancelButtonText("No Password") input_dialog.setLabelText("Please enter your Masterpassword") input_dialog.setWindowTitle("Masterpassword") input_dialog.setModal(False) while crypt_key is None: if input_dialog.exec_() == QInputDialog.Rejected: crypt_key = u"0238jh74ngz23v84m90fcqewmn4f89" else: crypt_key = input_dialog.textValue().strip() if not QtStarter.check_master_password(crypt_key): crypt_key = None input_dialog.setLabelText("Wrong Masterpassword, try again!") QtStarter.save_masterpassword_check(crypt_key) crypt = Coding(crypt_key.encode('utf-8')) self.window = ControlMainWindow(crypt) self.timer = threading.Timer(0.001, self.update_server_status, kwargs={'window': self.window}).start() self.window.show() ret = self.app.exec_() if self.timer is not None: self.timer.cancel() return ret
def get_text(parent=None, title='Input Text Value', label='Value:', default_value=None): input_dialog = QInputDialog(parent) input_dialog.setInputMode(InputDialog.TextInput) input_dialog.setWindowTitle(title) input_dialog.setLabelText(label) input_dialog.setOkButtonText('确定') input_dialog.setCancelButtonText('取消') if parent: input_dialog.setFont(parent.font()) return default_value if not input_dialog.exec_( ) else input_dialog.textValue()
def get_int(parent=None, title='Input Int Value', label='Value:', default_value=None, minimum=1, maximum=100): input_dialog = QInputDialog(parent) input_dialog.setInputMode(InputDialog.IntInput) input_dialog.setWindowTitle(title) input_dialog.setLabelText(label) input_dialog.setOkButtonText('确定') input_dialog.setCancelButtonText('取消') input_dialog.setIntRange(minimum, maximum) input_dialog.setIntValue(default_value or minimum) if parent: input_dialog.setFont(parent.font()) return default_value if not input_dialog.exec_( ) else input_dialog.intValue()
def get_double(parent=None, title='Input Double Value', label='Value:', default_value=None, decimals=1, minimum=1, maximum=1e9): input_dialog = QInputDialog(parent) input_dialog.setInputMode(InputDialog.DoubleInput) input_dialog.setWindowTitle(title) input_dialog.setLabelText(label) input_dialog.setOkButtonText('确定') input_dialog.setCancelButtonText('取消') input_dialog.setDoubleDecimals(decimals) input_dialog.setDoubleRange(minimum, maximum) input_dialog.setDoubleValue(default_value or minimum) if parent: input_dialog.setFont(parent.font()) return default_value if not input_dialog.exec_( ) else input_dialog.doubleValue()
def _renameItem(self): item = self._list.currentItem() input_dialog = QInputDialog(self.parentWidget(), Qt.WindowSystemMenuHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint) font = input_dialog.font() font.setPixelSize(16) input_dialog.setFont(font) input_dialog.setMinimumWidth(300) input_dialog.setInputMode(QInputDialog.TextInput) input_dialog.setWindowTitle("Renommer l'analyse") input_dialog.setLabelText("Nouveau nom pour '%s' :" % item.data(Qt.UserRole + 1)) input_dialog.setTextValue(item.data(Qt.UserRole + 1)) input_dialog.setOkButtonText("OK") input_dialog.setCancelButtonText("Annuler") if not input_dialog.exec_(): return new_name = input_dialog.textValue() if self._analysis is None: return if new_name == self._analysis.parameters().name(): return regexp = QRegExp("^[a-zA-Z0-9_-#éèêëàîï ]{5,30}$") if not regexp.exactMatch(new_name): QMessageBox.warning(self, "Nouveau nom invalide", "Caractères autorisés : alphanumérique, espace, #, - et _ avec une longueur maximale de 30 caractères") return self._analysis.parameters().setName(new_name) HistoryManager.renameAnalysis(item.data(Qt.UserRole), self._analysis) current_row = self._list.currentRow() self.reset(self._analysis) self._list.setCurrentRow(current_row) self.currentAnalysisChanged.emit(self._analysis)
def get_auth_code(self, opener, request): """ :param opener: urllib.request.build_opener for sending an authcode per mail :param request: request to send using the given opener :return: the authcode """ inputDialog = QInputDialog(self) inputDialog.setInputMode(QInputDialog.TextInput) inputDialog.setCancelButtonText("Cancel") inputDialog.setLabelText("Please enter your Authcode") inputDialog.setWindowTitle("TwoFactorAuth") inputDialog.setModal(True) response = None if inputDialog.exec_() == QInputDialog.Rejected: # send mail return None, None else: return response, inputDialog.textValue().strip() inputDialog.setCancelButtonText("Cancel") if inputDialog.exec_() == QInputDialog.Rejected: return response, None return response, inputDialog.textValue().strip()