def login_handler(self): """ To limit access of individual options in a project, to specific users, require that users login with valid passwords, based on glb.admin_list. If login is valid, set glb.current_user to user_name. Then, at the begining of each restricted option, check if current_user is authorized or not to continue ... For example, see admin_option_handler() above """ user, ok_ = W.QInputDialog().getText(self, "Enter", "User name:".ljust(60), W.QLineEdit.Normal) if ok_ and user: passwd, ok_ = W.QInputDialog().getText(self, "Enter", "Password:"******"color: green;">Login and/or password are accepted - \nlogged in as \n{}</h3>'.format( user) notify_("VALID", msg) return glb.current_user = "******" msg = '<h3 style="color: red;">Login and/or password are invalid - \nlogged in as </h3>\nGuest' notify_("INVALID", msg)
def _get_item_from_dialog(self): heads = [i for i in self._data.head(0)] head1, ok1 = QtWidgets.QInputDialog().getItem( self, 'First graph', 'Select the first graph.', heads, 0, False) head2, ok2 = QtWidgets.QInputDialog().getItem( self, 'Second graph', 'Select the second graph.', heads, 0, False) if ok1 and ok2: # generate graph self._generate_graph(head1, head2) else: # it must need to select two items pass
def rename_chain(self): new_name, ok = QtWidgets.QInputDialog(self).getText( self, f"Rename '{self.chain_name}'", "New name:") if ok: if new_name == "" or new_name.isspace(): error_dialog = QtWidgets.QMessageBox(parent=self) error_dialog.setWindowTitle("Rename failed") error_dialog.setText("Error") error_dialog.setInformativeText("New name can not be empty.") error_dialog.setIcon(QtWidgets.QMessageBox.Critical) error_dialog.exec_() else: try: chain_handler.rename_chain(self.chain_name, new_name) self.parent().load_chain_layout_ui() except NameError: error_dialog = QtWidgets.QMessageBox(parent=self) error_dialog.setWindowTitle("Rename failed") error_dialog.setText("Error") error_dialog.setInformativeText( f"Error: '{new_name}' is already in use.") error_dialog.setIcon(QtWidgets.QMessageBox.Critical) error_dialog.exec_() except: raise
def createFolder(self, scene=None): text, ok = QtWidgets.QInputDialog().getText(self, 'New Folder', 'Folder Name') if ok and text: self.core.createFolder(text, scene=scene) self.fillSceneLevel()
def build_widgets(self): self.timer = QtCore.QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.get_message_callback) self.timer.start() self.text_input = QtWidgets.QLineEdit() self.text_input.setPlaceholderText("Message") self.text_input2 = QtWidgets.QLineEdit() self.text_input2.setPlaceholderText("Name") self.textedit = QtWidgets.QTextEdit() self.textedit.setReadOnly(True) self.button = QtWidgets.QPushButton() self.button.setText("Send") self.button2 = QtWidgets.QPushButton() self.button2.setText("Change User Name") self.dialog = QtWidgets.QInputDialog() self.label = QtWidgets.QLabel()
def record(self, button): text, ok = QtWidgets.QInputDialog().getText(self, "Emotion Recognition", "Enter Your Name:") if ok and text: self.speaker = text print "Speaker: " + self.speaker wFile = "Test/" + self.speaker + ".wav" start_record(self, wFile, 5, self.state) state = "File saved as " + self.speaker self.repaint() print 'File saved as ' + self.speaker + ".wav" self.add_files() fFile = "feat/Test/" + self.speaker + ".htk" try: # call MFCC feature extraction subroutine f, E, fs = mfcc(wFile, self.winlen, self.ovrlen, self.pre_coef, self.nfilter, self.nftt) # VAD part if self.opts == 1: f = vad_thr(f, E) # Energy threshold based VAD [comment this line if you would like to plugin the rVAD labels] elif self.opts == 0: l = numpy.loadtxt('..corresponding vad label file') # [Plugin the VAD label generated by rVAD matlab] if (len(f) - len(l)) == 1: # 1-[end-frame] correction [matlab/python] l = numpy.append(l, l[-1:, ]) elif (len(f) - len(l)) == -1: l = numpy.delete(l, -1) if (len(l) == len(f)) and (len(numpy.argwhere(l == 1)) != 0): idx = numpy.where(l == 1) f = f[idx] else: print "mismatch frames between: label and feature files or no voice-frame in VAD" exit() # Zero mean unit variance normalize after VAD f = cmvn(f) # write the VAD+normalized features in file if not os.path.exists(os.path.dirname(fFile)): # create director for the feature file os.makedirs(os.path.dirname(fFile)) writehtk(fFile, f, 0.01) except: print("Fail1..%s ---> %s\n" % (wFile, fFile)) if button.text() == "Live Detection": self.test_emotion(name=self.speaker) else: self.state = "Not valid Name" self.repaint() return
def _transformBake(self): allSel = mc.ls(sl=True) if len(allSel) < 1: msgBox = QtWidgets.QMessageBox(self) msgBox.setWindowTitle("Warning!") msgBox.setText( "Please select at least one vertex or transform to bake.") msgBox.exec_() tools.logger.info( 'Please select at least one vertex or transform to bake.') else: inputDialog = QtWidgets.QInputDialog() inputDialog.setInputMode(QtWidgets.QInputDialog.DoubleInput) inputDialog.setDoubleDecimals(2) inputDialog.setDoubleMinimum(0.01) value, ok = inputDialog.getDouble(self, 'Sample By', 'Each ### frames:', 1.0) if ok: try: mc.refresh(suspend=True) tools.transformBake(allSel, value) except: pass finally: mc.refresh(suspend=False) #Done! msgBox = QtWidgets.QMessageBox(self) msgBox.setWindowTitle("Done!") msgBox.setText("Done baking transforms.") msgBox.exec_()
async def on_use_nintendont_backend(self): dialog = QtWidgets.QInputDialog(self.parent) dialog.setModal(True) dialog.setWindowTitle("Enter Wii's IP") dialog.setLabelText( "Enter the IP address of your Wii. " "You can check the IP address on the pause screen of Homebrew Channel." ) if self.options.nintendont_ip is not None: dialog.setTextValue(self.options.nintendont_ip) if await async_dialog.execute_dialog(dialog) == dialog.Accepted: new_ip = dialog.textValue() if new_ip != "": if not self.options.is_alert_displayed( InfoAlert.NINTENDONT_UNSTABLE): await async_dialog.warning( self.parent, "Nintendont Limitation", "Warning: The Nintendont integration isn't perfect and is known to " "crash.") self.options.mark_alert_as_displayed( InfoAlert.NINTENDONT_UNSTABLE) with self.options as options: options.nintendont_ip = new_ip options.game_backend = GameBackendChoice.NINTENDONT self.game_connection.set_backend(NintendontBackend(new_ip)) self.refresh_backend()
def add_item(self): item, accept = QtWidgets.QInputDialog().getText( self, 'Add new command', 'Shell command:') if item and accept: list_item = QtWidgets.QListWidgetItem(item) self.list_widget.addItem(list_item) self.writeFile()
def new_fav_list_dialog(self): dialog = QtWidgets.QInputDialog(self) dialog.setWindowTitle("New pin list") dialog.setLabelText("List name") func = lambda: self.add_fav_list(widget_data={NAME: dialog.textValue()}) dialog.accepted.connect(func) dialog.move(self.fav_combo.mapToGlobal(self.fav_combo.pos())) dialog.show()
def set_project(self, item_list): items = File.File( package.get("LibData/project_data.yaml").replace( "\\", "/")).read_data_from_file() project_data = QtWidgets.QInputDialog().getItem( self, "Get item", "Project:", items, 0, False)[0] for item in item_list: item.menu.set_project(project_data)
def edit_comment(self): comment, ok = QtWidgets.QInputDialog(self).getText( self, "Comment", "Set comment:", QtWidgets.QLineEdit.Normal, self.comment) if comment and ok: chain_handler.edit_chain_comment(self.chain_name, comment, self.year, self.month, self.day) self.load_comment(comment) self.load_context_menu()
async def on_login_as_guest_button(self): dialog = QtWidgets.QInputDialog(self) dialog.setModal(True) dialog.setWindowTitle("Enter guest name") dialog.setLabelText("Select a name for the guest account:") if await async_dialog.execute_dialog(dialog) != dialog.Accepted: return await self.network_client.login_as_guest(dialog.textValue())
def editLabel(self) -> QtWidgets.QInputDialog: """Simple dialog for editing the label (and element name).""" dlg = QtWidgets.QInputDialog(self.scene().views()[0]) dlg.setWindowTitle("Edit Name") dlg.setInputMode(QtWidgets.QInputDialog.TextInput) dlg.setTextValue(self.text()) dlg.setLabelText("Rename:") dlg.textValueSelected.connect(self.labelChanged) dlg.open() return dlg
async def _on_menu_action_map_tracker(self): dialog = QtWidgets.QInputDialog(self) dialog.setWindowTitle("Map Tracker") dialog.setLabelText("Select preset used for the tracker.") dialog.setComboBoxItems( [preset.name for preset in self._preset_manager.all_presets]) dialog.setTextValue(self._options.selected_preset_name) result = await async_dialog.execute_dialog(dialog) if result == QtWidgets.QDialog.Accepted: preset = self._preset_manager.preset_for_name(dialog.textValue()) self.open_map_tracker(preset.get_preset().layout_configuration)
def rename_fav_list_dialog(self): dialog = QtWidgets.QInputDialog(self) dialog.setWindowTitle("Rename pin list") dialog.setLabelText("New name") dialog.setTextValue(self.fav_combo.currentText()) func = lambda: self.set_fav_list_name(self.fav_combo.currentIndex(), dialog.textValue()) dialog.accepted.connect(func) dialog.move(self.fav_combo.mapToGlobal(self.fav_combo.pos())) dialog.show()
def tabRenameDialog(self, index: int) -> QtWidgets.QDialog: if index == -1 or not self.view.stack.widget(index).editable: return dlg = QtWidgets.QInputDialog(self) dlg.setWindowTitle("Rename") dlg.setLabelText("Name:") dlg.setTextValue(self.tabText(index)) dlg.setInputMode(QtWidgets.QInputDialog.TextInput) dlg.textValueSelected.connect(lambda s: self.setTabText(index, s)) dlg.open() return dlg
def uninstall_app(self): Alive_out = subprocess.Popen( r'D:\NintendoSDK\NintendoSDK_10_4_0\NintendoSDK\Tools\CommandLineTools\ControlTarget.exe check-alive --any' ) Connection_out = subprocess.Popen( r'D:\NintendoSDK\NintendoSDK_10_4_0\NintendoSDK\Tools\CommandLineTools\ControlTarget.exe connect' ) if Alive_out.wait() != 0 or Connection_out.wait() != 0: sms_box = QtWidgets.QMessageBox() sms_box.setWindowTitle("Connection Information") sms_box.setWindowIcon(QIcon("Main_Logo.ico")) sms_box.setText( "<b>No Target found and Failed to uninstall application</b>") sms_box.setInformativeText( "Please connect/reconnect console to PC using Type C cable or wake it up from sleep mode." ) sms_box.setIcon(sms_box.Information) sms_box.exec_() else: res = subprocess.check_output( r'D:\NintendoSDK\NintendoSDK_10_4_0\NintendoSDK\Tools\CommandLineTools\ControlTarget.exe list-application' ) cmd_result = res.decode("latin1", 'ignore').split('\n') result = [] for i in range(2, len(cmd_result) - 3): if cmd_result[ i] == '0x0100000000002065 1.0.0 DevMenu Application \r': continue result.append(cmd_result[i]) #print(result) # if the applications are not installed (exclude DevMenu - risk to uninstall it)- list is empty if len(result) == 0: self.sms_box = QtWidgets.QMessageBox() self.sms_box.setWindowTitle("App Information") #self.sms_box.setStyleSheet('font:bold') self.sms_box.setText( "No Games or Applications installed on the console!!!") self.sms_box.setInformativeText( "Please install a Game/Application on console first.") self.sms_box.setIcon(self.sms_box.Information) self.sms_box.exec_() #Else populate list to QinputDialog and launch selected applicaion else: self.input_dialogue = QtWidgets.QInputDialog() text, ok = self.input_dialogue.getItem( self, "Application selection", "Select an application to uninstall:", result, 0, False) if ok: comm = r'D:\NintendoSDK\NintendoSDK_10_4_0\NintendoSDK\Tools\CommandLineTools\ControlTarget.exe uninstall-application ' + text subprocess.Popen(comm) else: self.input_dialogue.close()
def input(label, title='Input', text=None): ''' Allows the user to respond with a text input If the okay button is pressed it returns the inputed text, otherwise None ''' dialog = QtWidgets.QInputDialog() text = dialog.getText(None, title, label, text=text) if text[1]: return text[0] else: return None
def renameTestCase(self, index): if self.testCaseStack.currentIndex() == self.testCaseStack.count() - 1: return dialog, ok = QtWidgets.QInputDialog().getText( self, "Rename Test Case", "Enter new name:", QtWidgets.QLineEdit.Normal) if ok and dialog: self.testCaseComboBox.setItemText(index, dialog) self.testCaseStack.widget(index).name = dialog
def fontsizeDialog(self) -> QtWidgets.QDialog: """Simple dialog for editing image font size.""" dlg = QtWidgets.QInputDialog(self) dlg.setWindowTitle("Fontsize") dlg.setLabelText("Fontisze:") dlg.setIntValue(self.options.font.pointSize()) dlg.setIntRange(2, 96) dlg.setInputMode(QtWidgets.QInputDialog.IntInput) dlg.intValueSelected.connect(self.options.font.setPointSize) dlg.intValueSelected.connect(self.refresh) dlg.open() return dlg
def insertNewTime(self): newTime, status = QtWidgets.QInputDialog().getText( self, "Enter the arrival time", "Arrival Time", QtWidgets.QLineEdit.Normal, str(datetime.datetime.now())) if status: Database.insertArrival( self.dbCxn, self.stopsList.currentItem().data(1337), self.routesList.currentItem().data(1337), DateTimeTools.dateAndTimeToDatetime( datetime.date.today(), Parser.parseTime(self.arrivalsList.currentItem().data(0))), datetime.datetime.strptime(newTime, "%Y-%m-%d %H:%M:%S.%f"))
def pack(self): ''' 消息处理 ''' msg = {} msg["auth"] = self.auth modes = ["broadcast", "solo", "list all users"] mode, ok = QtWidgets.QInputDialog().getItem(self, "mode", "mode: ", modes, 0, False) if ok: if mode == "solo": msg["type"] = "solo" who, ok = QtWidgets.QInputDialog().getText(self, "to who", "to: ", QtWidgets.QLineEdit.Normal, None) if ok: msg["toWho"] = who else: msg["type"] = "" if self.inputEdit.toPlainText() == "": msg["type"] = "" warning = QtWidgets.QMessageBox() warning.setText("say something") warning.exec_() else: msg["text"] = self.inputEdit.toPlainText() elif mode == "broadcast": msg["type"] = "broadcast" if self.inputEdit.toPlainText() == "": msg["type"] = "" warning = QtWidgets.QMessageBox() warning.setText("say something") warning.exec_() else: msg["text"] = self.inputEdit.toPlainText() elif mode == "list all users": msg["type"] = "show" msg = json.dumps(msg) msg = bytes(msg, encoding='utf-8') self.inputEdit.clear() return msg
def create_shared_library(selection): import flame import os from PySide2 import QtWidgets dlg = QtWidgets.QInputDialog() dlg.setLabelText("Enter the artist name") if dlg.exec_(): name = str(dlg.textValue()) shared = flame.project.current_project.create_shared_library(name) shared.acquire_exclusive_access() shared.create_folder("from_" + name) shared.create_folder("to_" + name) shared.release_exclusive_access()
def Changevalue(self): Dialog = QtWidgets.QInputDialog() Dialog.setInputMode(QtWidgets.QInputDialog.DoubleInput) Dialog.setDoubleDecimals(self.Decimals) Dialog.setDoubleRange(self.Min, self.Max) Dialog.setDoubleStep(self.Step) Dialog.setDoublevalue(self.value) Dialog.setLabelText("Please entre a new value (min = " + str(self.Min) + ", max = " + str(self.Max) + ")") Dialog.setModal(True) Dialog.setWindowTitle("Modify value") Dialog.exec() if Dialog.result(): self.SetValue(Dialog.doublevalue()) self.Signals.fSignal.emit(self.value)
def addNotebook(window, check): # input name if check: item = window.ui.treeWidget.topLevelItem(0) else: item = window.ui.treeWidget.currentItem() text, ok = QtWidgets.QInputDialog().getText( window, "Groot", "Enter the name for new notebook - ", flags=QtCore.Qt.Dialog) if ok is True: if str(text) != "": name = str(text) else: name = "Untitled" else: return deets = treeHandling.itemVal(item) # Make changes to fileStructure randomString = datetime.datetime.now().strftime("%d%m%Y%H%M%S") newdict = {} newdict["name"] = name newdict["expanded"] = {} if (item.parent() is None): deets[1][deets[0]][randomString] = newdict else: deets[1][deets[0]]["expanded"][randomString] = newdict treeHandling.saveUpdatedJson(deets[2]) # Update treeWidget newItem = QtWidgets.QTreeWidgetItem() newItem.setText(0, name) newItem.setFlags(QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/icons/Icons/16x16/subfolder_light.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) newItem.setIcon(0, icon) item.addChild(newItem) item.setExpanded(True) item.treeWidget().setCurrentItem(newItem)
def renamePreset(self): presetItem = self.actionItem presetName = presetItem.text() inputDialog = QtWidgets.QInputDialog() newName, ok = inputDialog.getText(self, "MIBView", "Rename Preset:", text=presetName) if newName and ok: try: presets = cfg.presets.copy() presets[newName] = presets.pop(presetName) cfg.set_presets(presets) cfg.saveConfig(cfg.configPath) presetItem.setText(newName) except Exception, e: utils.error(e)
def uirecherchemotcle(self, fenetregestionlien): """Fenêtre qui s'ouvre dès que l'on clique sur le btn_motcle pour la recherche par mot-cle.""" # création de la fenêtre self.fenetregest_motcle = QtWidgets.QInputDialog(fenetregestionlien) self.fenetregest_motcle.setGeometry(500, 300, 200, 100) self.fenetregest_motcle.setWindowTitle("Recherche par mot-clef") self.fenetregest_motcle.setModal(True) # # Mise en place d'un layout pour la fenêtre # self.glimotcle = QtWidgets.QGridLayout(self.fenetregest_motcle) # # # Création d'un widget label pour expliquer quoi faire # self.laimotcle = QtWidgets.QLabel(self.fenetregest_motcle) # #Ajout du label au gridlayout de la fenêtre # self.glimotcle.addWidget(self.laimotcle, 0, 0, 1, 2) # # création du texte du label # self.laimotcle.setText("Veuillez entre le(s) mot(s) pour la recherche : (séparés par une virgule)") # # # création d'un QlineEdit pour entrer les mots-clefs # self.leimotcle = QtWidgets.QLineEdit(self.fenetregest_motcle) # # Ajout du widget QlineEdit au layout de la fenêtre # self.glimotcle.addWidget(self.leimotcle, 1, 0, 1, 3) # # # création d'un bouton ok # self.btn_imotcle = QtWidgets.QPushButton("OK", self.fenetregest_motcle) # # Ajout du bouton ok à la fenêtre # self.glimotcle.addWidget(self.btn_imotcle, 2, 1, 1, 1) # # self.fenetregest_motcle.show() # # # récupération des données du QLineEdit # self.btn_imotcle.clicked.connect(return motclef) motclef, ok = self.fenetregest_motcle.getText( fenetregestionlien, "Mot-clef", """Veuillez entre le(s) mot(s) pour la recherche : (séparés par une virgule)""") if ok: return motclef else: self.fenetregest_motcle.close()
def addTestCase(self): testCaseTitle, ok = QtWidgets.QInputDialog().getText( self, "Test Case Name", "Enter test case name:", QtWidgets.QLineEdit.Normal) if ok and testCaseTitle: self.testCaseStack.insertWidget( self.testCaseStack.count() - 1, self.TestCase(testCaseTitle, self.defaultTestValue, self.defaultMatchType, self.defaultStartToken, self.defaultEndToken)) self.testCaseComboBox.insertItem(self.testCaseComboBox.count() - 1, testCaseTitle) self.changeTestCase(self.testCaseStack.count() - 2) self.updateTotalPoints() self.checkEnableWidgets() else: #if user cancels, test case switches to last test case if self.testCaseStack.count() > 1: self.changeTestCase(self.testCaseStack.count() - 2) self.checkEnableWidgets()
def add_new_feed(self): add_dialog = qtw.QInputDialog() self.releaseKeyboard() feed_url, ok = add_dialog.getText( self, "Enter Feed URL", "Feed Url:", qtw.QLineEdit.Normal, "" ) try: urls = db.get_podcast_urls() valid_feed = test_feed(feed_url) if not valid_feed or feed_url in urls: logger.error(f"{feed_url} is ain invalid feed.") else: # if no feeds are in database logger.info(f"{feed_url} is a valid feed.") db.parse_xmls_to_database(feed_url) self.load_feed_list() except Exception as e: logger.error(f"Invalid feed entered:\n{e}") self.grabKeyboard()