def AddBookFromURL(self): # Create Resized Input Dialog dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) dlg.setLabelText('Enter URL:') dlg.setTextValue('https://www.readlightnovel.org/only-i-level-up') dlg.setWindowTitle('Add Novel') dlg.resize(500, 100) # If Cancelled if dlg.exec_() == 0: return # Get URL url = dlg.textValue() # Check URL if self.settings['MainURL'] not in url: print('{0} not in {1}'.format(self.settings['MainURL'], url)) return # Dump Info try: info = Utils.dumpInfo(url, self.settings) except AttributeError: print('Incorrect URL') return # Dump Cover Utils.dumpCover(info, self.settings) self.UpdateList()
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 annotate_state(self, id): dialog = QInputDialog() dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText("Annotation:") dialog.resize(400, 100) if dialog.exec_(): self.store_annotation(id, dialog.textValue()) self.redraw_graph()
def on_add(self): dialog = QInputDialog(self) dialog.setLabelText("Enter appconfig.json URL") if dialog.exec_() == QInputDialog.Rejected: return app_url = dialog.textValue().strip() self.host.app_store.add_app_ui([app_url])
def add_rule(self): input = QInputDialog(self.window) input.setWindowTitle("Add exclude rule") input.setLabelText("Exclude rule (eg: C:\\Users\\*\\Volumes\\*.iso)") if input.exec_(): exclude_rule = input.textValue() exclude_rule = exclude_rule.replace(os.sep, "/") self.exclude_rules.add(exclude_rule) self.reload_exclude_rules()
def edit_watcher(self): index = self.watcherlist.currentRow() addr = self.workspace.cartprograph.watchers[index][0] dialog = QInputDialog() dialog.setInputMode(QInputDialog.TextInput) dialog.setLabelText("Edit watcher @ " + hex(addr) + ":") dialog.setTextValue(", ".join( self.workspace.cartprograph.watchers[index][1])) dialog.resize(500, 100) if dialog.exec_(): self.workspace.cartprograph.watchers[index][ 1] = self._process_registers(dialog.textValue()) self.update_watcherlist()
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 on_mkdir(self): dialog = QInputDialog(self) dialog.setLabelText("Directory name") if dialog.exec_() == QInputDialog.Rejected: return dirname = dialog.textValue().strip() if not dirname or "/" in dirname: QMessageBox.critical(self, "Invalid input", "This directory name cannot be used") return self.host.app_store.mkdir(dirname)
def get_charname(self): """ :param mailurl: url to call for sending an authcode per mail :return: the authcode """ inputDialog = QInputDialog(self) inputDialog.setInputMode(QInputDialog.TextInput) inputDialog.setLabelText("Please enter a Charname") inputDialog.setWindowTitle("Charname Challange") inputDialog.setModal(True) if inputDialog.exec_() == QInputDialog.Rejected: return None return inputDialog.textValue().strip()
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()
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 askGenericText(message, title, parent=None, previous=""): """Uses `QInputDialog` to ask a text answer for a given question. Parameters: message: the question to be displayed title: the window title parent (optional, default None): the parent of the window Output: return a tuple containing the text as first element and True/False (depending if the user selected "Ok" or "Cancel") as the second element """ dialog = QInputDialog(parent) dialog.setInputMode(QInputDialog.TextInput) dialog.setWindowTitle(title) dialog.setLabelText(message) dialog.setTextValue(previous) out = dialog.exec_() return dialog.textValue(), out
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 GenerateBook(self): wdgList = self.ui.wdgList # Get Selected List selected = [ item.text().split(' | ') for item in wdgList.selectedItems() ] if len(selected) <= 0: return # Dump not downloaded chapters notDumped = [x for x in selected if x[1][-1] != ']'] # Download chapters if not self.downloadChapters(notDumped): self.UpdateList() # If canceled stop epub generation return self.UpdateList() # Update selected list selected = [[x[0][1:], x[1][:-1]] for x in selected if x[1][-1] == ']'] selected += notDumped # Get dicts from Info dictionary chapters = [ chp for chp in self.info['chapters'] for volume, name in selected if name == chp['name'] and volume == chp['volume'] ] # Generate Title for book volume = chapters[0]['volume'] for chapter in chapters: if chapter['volume'] != volume or 'chapters' in volume.lower(): volume = 'Chapters:' title = self.info['title'] + ' ' + volume try: # If chapters are not from the same volume if volume == 'Chapters:': numbers = [ int( float(''.join(s for s in name if s.isdigit() or s == '.' or s == '-'))) for name in selected ] numbers = list(set(numbers)) # Generate ranges for number list ranges = Utils.ranges(numbers) for r in ranges: if r[0] == r[1]: title += ' {0},'.format(r[0]) else: title += ' {0} - {1},'.format(r[0], r[1]) if title[-1] == ',': title = title[:-1] except ValueError: pass # Show Title Input Dialog dlg = QInputDialog() dlg.setInputMode(QInputDialog.TextInput) dlg.setLabelText('Enter Title:') dlg.setWindowTitle('Select Book Title') dlg.setTextValue(title) dlg.resize(500, 100) # If Cancelled if dlg.exec_() == 0: return # Get URL title = dlg.textValue() # Show File Dialog ans = QFileDialog.getSaveFileName(caption='Save ePUB', filter='ePUB (*.epub)', dir=title + '.epub') filename = ans[0] # Add file format if not present if filename[-5:] != '.epub': filename += '.epub' # Generate ePUB file Utils.generateEPUB(filename, title, self.info, chapters, self.settings)