Python源码示例:PyQt5.QtWidgets.QInputDialog.getText()

示例1
def ask_for_password(username, host, message=None):
        if not SshPassCache.parent_window:
            raise Exception('SshPassCache not initialized')

        def query_psw(msg):
            password, ok = QInputDialog.getText(SshPassCache.parent_window, 'Password Dialog',
                                                msg, echo=QLineEdit.Password)
            return password, ok

        if not message:
            message = 'Enter password for ' + username + '@' + host + ':'

        if threading.current_thread() != threading.main_thread():
            password, ok = WndUtils.call_in_main_thread(query_psw, message)
        else:
            password, ok = query_psw(message)

        if not ok:
            raise CancelException
        return password 
示例2
def make_further_instructions(self, pr):
        def further_instructions():
            response = QMessageBox.information(self, "Next Step", "To continue, send the necessary amounts of Bitcoin to the addresses specified in the 'Outputs' field above. Once broadcast, press Yes to Continue or Cancel to quit.", QMessageBox.Cancel | QMessageBox.Yes, QMessageBox.Cancel)
            if response == QMessageBox.Cancel:
                sys.exit()
            elif response == QMessageBox.Yes:
                if pr.details.payment_url:
                    raw_tx, okPressed1 = QInputDialog.getText(self, "Enter Raw Transaction","Enter the hex of the transaction that was just made:", QLineEdit.Normal, "")
                    if okPressed1 and raw_tx != '':
                        ref_addr, okPressed2 = QInputDialog.getText(self, "Enter Refund Address","Enter a refund address:", QLineEdit.Normal, "")
                        if okPressed2 and ref_addr != '':
                            try:
                                result = pr.send_ack(raw_tx.strip(), ref_addr.strip())
                                if result[0]:
                                    QMessageBox.information(self, "Complete!", "Payment request successful: " + result[1] + "\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
                                    sys.exit()
                                else:
                                    QMessageBox.error(self, "Error!", "Payment request was not successful: " + result[1] + "\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
                                    sys.exit()
                            except:
                                QMessageBox.error(self, "Error!", "There was an error parsing the raw transaction or address. Please restart and try again.\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
                                sys.exit()
                                
        return further_instructions 
示例3
def prompt_extractor(self, item):
        extractor = extractors[item.data(Qt.UserRole)]
        inputs = []
        if not assert_installed(self.view, **extractor.get('depends', {})):
            return
        
        if not extractor.get('pick_url', False):
            files, mime = QFileDialog.getOpenFileNames()
            for path in files:
                inputs.append((path, Path(path).stem))
        else:
            text, good = QInputDialog.getText(self.view, ' ', 'Input an URL:')
            if text:
                url = urlparse(text)
                inputs.append((url.geturl(), url.netloc))
        
        if inputs:
            wait = QProgressDialog('Extracting .proto structures...', None, 0, 0)
            wait.setWindowTitle(' ')
            self.set_view(wait)
            
            self.worker = Worker(inputs, extractor)
            self.worker.progress.connect(self.extraction_progress)
            self.worker.finished.connect(self.extraction_done)
            self.worker.start() 
示例4
def getDevice(self):
        text,ok=(lambda adbList:QInputDialog.getItem(self,'更改安卓设备','在下拉列表中选择一个设备',adbList,adbList.index(self.serial)if self.serial and self.serial in adbList else 0))([i for i,j in ADB().devices()if j=='device'])
        #text,ok=QInputDialog.getText(self,'更改安卓设备','填写',text='emulator-5554')
        if ok and text:self.serial=text 
示例5
def adbConnect(self):
        text,ok=QInputDialog.getText(self,'连接远程设备','设备地址',text='localhost:5555')
        if ok and text:ADB(text)#os.system(f'adb connect {text}') 
示例6
def _add_provider(self):
        """Adds an empty provider box to be filled out by the user."""

        self._collapse_boxes()
        # Show quick user input dialog
        provider_name, ok = QInputDialog.getText(self, "New ORS provider", "Enter a name for the provider")
        if ok:
            self._add_box(provider_name, 'https://', '', new=True) 
示例7
def prompt_rename(self):
        text, good = QInputDialog.getText(self.app.view, ' ', 'Rename this field:', text=self.text(0).strip('+ '))
        if text:
            if not match('^[a-zA-Z0-9_]+$', text):
                QMessageBox.warning(self.app.view, ' ', 'This is not a valid alphanumeric name.')
                self.prompt_rename()
            else:
                try:
                    if self.do_rename(text):
                        return
                except Exception:
                    pass
                QMessageBox.warning(self.app.view, ' ', 'Field was not found in .proto, did you edit it elsewhere?') 
示例8
def add_tab_data(self):
        text, good = QInputDialog.getText(self.view, ' ', 'Field name:')
        if text:
            ProtocolDataItem(self.fuzzer.getTree, text, '', self).edit() 
示例9
def loguj(self):
        login, ok = QInputDialog.getText(self, 'Logowanie', 'Podaj login:')
        if ok:
            haslo, ok = QInputDialog.getText(self, 'Logowanie', 'Podaj haslo:')
            if ok:
                if not login or not haslo:
                    QMessageBox.warning(
                        self, 'Błąd', 'Pusty login lub hasło!', QMessageBox.Ok)
                    return
                QMessageBox.information(
                    self, 'Dane logowania',
                    'Podano: ' + login + ' ' + haslo, QMessageBox.Ok) 
示例10
def on_btn_add_separator_clicked(self):
        sep, ok = QInputDialog.getText(self, "Enter Separator", "Separator:", text=",")
        if ok and sep not in (self.ui.comboBoxCSVSeparator.itemText(i) for i in
                              range(self.ui.comboBoxCSVSeparator.count())):
            if len(sep) == 1:
                self.ui.comboBoxCSVSeparator.addItem(sep)
            else:
                Errors.generic_error("Invalid Separator", "Separator must be exactly one character.") 
示例11
def create_directory(self):
        index = self.model().mapToSource(self.rootIndex())  # type: QModelIndex

        if not index.isValid():
            return

        model = self.model().sourceModel()
        dir_name, ok = QInputDialog.getText(self, self.tr("Create Directory"), self.tr("Directory name"))

        if ok and len(dir_name) > 0:
            if not model.mkdir(index, dir_name).isValid():
                QMessageBox.information(self, self.tr("Create Directory"), self.tr("Failed to create the directory")) 
示例12
def prompt_for_grid_name(grid_name, parent=None):
    title = "{} - Choose a name".format(APP_NAME)
    label = "Please choose a name for this connection:"
    if grid_name:
        label = (
            '{} is already connected to "{}".\n\n'
            "Please choose a different name for this connection".format(
                APP_NAME, grid_name
            )
        )
    return QInputDialog.getText(parent, title, label, 0, grid_name) 
示例13
def prompt_for_folder_name(folder_name, grid_name, parent=None):
    return QInputDialog.getText(
        parent,
        "Folder already exists",
        'You already belong to a folder named "{}" on\n'
        "{}; Please choose a different name.".format(folder_name, grid_name),
        0,
        folder_name,
    ) 
示例14
def add(self):
        # 工具栏功能
        if not self.state:
            self.get_file()
            if self.fname:
                self.name, ok = QInputDialog.getText(self, '文件', '应用名称')
                if ok and self.name:
                    self.state = True
                    self.setText(self.name)
                else:
                    self.fname = None 
示例15
def keyPressEvent(self, e):
        if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_F:
            text, okPressed = QInputDialog.getText(self, "Find", "Find what: ")

            self.setSelectionBackgroundColor(QColor("#6be585"))

            if okPressed:
                if text == "":
                    text = " "
                    self.dialog.noMatch(text)

                self.searchtext = text

                """
                This is the way to implement a search function using QScintilla 
                http://pyqt.sourceforge.net/Docs/QScintilla2/classQsciScintilla.html#a37ac2bea94eafcfa639173557a821200
                """

                if self.findFirst(
                    self.searchtext, False, True, False, True, True, -1, -1, True, False
                ):
                    pass
                else:
                    self.dialog.noMatch(self.searchtext)

        if e.key() == Qt.Key_F3:
            self.findNext()
            self.setSelectionBackgroundColor(QColor("#6be585"))

        if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_L:
            self.setCursorPosition(self.line, self.column + 1)
            return
        if e.modifiers() == Qt.ControlModifier and e.key() == 77:

            self.setCursorPosition(self.line + 1, self.column)
            return
        if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_J:
            self.setCursorPosition(self.line, self.column - 1)

        if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_I:
            self.setCursorPosition(self.line - 1, self.column)

        if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_T:
            self.parent.parent.realterminal()
            return

        super().keyPressEvent(e) 
示例16
def doVowelHarmony(self):

        text = QInputDialog.getText(self, 'Vowel harmony', 'Which feature is unique to vowels? In SPE this is [+voc]')

        text = text[0].lstrip('[').rstrip(']')
        if not self.corpusHasFeature(text):
            return
        self.harmony_feature = text
        self.corpusModel.corpus.add_tier('AutoGeneratedVowels',text)

        inventory = [seg for seg in self.corpusModel.corpus.inventory if seg.features[text[1:]]==text[0]]
        probs = defaultdict(list)
        for pair in itertools.product(inventory,repeat=2):
            pair = (pair[0].symbol, pair[1].symbol)
            try:
                mi = mutual_information.pointwise_mi(self.corpusModel.corpus, pair, 'AutoGeneratedVowels')
                probs[pair[0]].append( (pair[1], mi) )
            except mutual_information.MutualInformationError:
                probs[pair[0]].append( (pair[1], '*') )

        harmonic_features = ['high', 'back', 'round']
        commentary = list()
        for feature in harmonic_features:
            plus = [seg for seg in inventory if seg.features[feature]=='+']
            minus = [seg for seg in inventory if not seg in plus]
            avg_pp_mi = list()
            avg_pm_mi = list()
            avg_mm_mi = list()
            avg_mp_mi = list()
            for seg in inventory:
                for seg2,mi in probs[seg.symbol]:
                    if mi == '*':
                        continue
                    seg2 = self.corpusModel.corpus.symbol_to_segment(seg2)
                    seg2_sign = seg.features[feature]
                    if seg in plus:
                        if seg2_sign == '+':
                            avg_pp_mi.append(mi)
                        else:
                            avg_pm_mi.append(mi)
                    elif seg in minus:
                        if seg2_sign == '-':
                            avg_mm_mi.append(mi)
                        else:
                            avg_mp_mi.append(mi)
            self.resultsLayout.addWidget(QLabel('Average [+{0}][+{0}] MI = {1}'.format(feature, avg_pp_mi)))
            self.resultsLayout.addWidget(QLabel('Average [+{0}][-{0}] MI = {1}'.format(feature, avg_pm_mi)))
            self.resultsLayout.addWidget(QLabel('Average [-{0}][-{0}] MI = {1}'.format(feature, avg_mm_mi)))
            self.resultsLayout.addWidget(QLabel('Average [-{0}][+{0}] MI = {1}'.format(feature, avg_mp_mi)))
            if avg_pp_mi > avg_pm_mi and avg_mm_mi > avg_mp_mi:
                commentary.append('There might be harmony based on {}'.format(feature))

        commentary = '\n'.join([c for c in commentary])
        self.outputHarmonyResults(avg_pp_mi,avg_pm_mi,avg_mm_mi,avg_mp_mi,commentary)
        self.corpusModel.corpus.remove_attribute('AutoGeneratedVowels')
        return