本文整理匯總了Python中PyQt5.QtWidgets.QInputDialog.getText方法的典型用法代碼示例。如果您正苦於以下問題:Python QInputDialog.getText方法的具體用法?Python QInputDialog.getText怎麽用?Python QInputDialog.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QInputDialog
的用法示例。
在下文中一共展示了QInputDialog.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ask_for_password
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: make_further_instructions
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: prompt_extractor
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: getDevice
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: adbConnect
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
def adbConnect(self):
text,ok=QInputDialog.getText(self,'連接遠程設備','設備地址',text='localhost:5555')
if ok and text:ADB(text)#os.system(f'adb connect {text}')
示例6: _add_provider
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: prompt_rename
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: add_tab_data
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
def add_tab_data(self):
text, good = QInputDialog.getText(self.view, ' ', 'Field name:')
if text:
ProtocolDataItem(self.fuzzer.getTree, text, '', self).edit()
示例9: loguj
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: on_btn_add_separator_clicked
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: create_directory
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: prompt_for_grid_name
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: prompt_for_folder_name
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: add
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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: keyPressEvent
# 需要導入模塊: from PyQt5.QtWidgets import QInputDialog [as 別名]
# 或者: from PyQt5.QtWidgets.QInputDialog import getText [as 別名]
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)