本文整理汇总了Python中PyQt4.Qt.QInputDialog.getText方法的典型用法代码示例。如果您正苦于以下问题:Python QInputDialog.getText方法的具体用法?Python QInputDialog.getText怎么用?Python QInputDialog.getText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QInputDialog
的用法示例。
在下文中一共展示了QInputDialog.getText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def __init__(self, pa, parent):
QDialog.__init__(self, parent)
TE_Dialog.__init__(self)
self.setupUi(self)
opts = smtp_prefs().parse()
self.test_func = parent.test_email_settings
self.test_button.clicked.connect(self.test)
self.from_.setText(unicode(self.from_.text())%opts.from_)
if pa:
self.to.setText(pa)
if opts.relay_host:
tmp_password=''
if opts.relay_prompt:
header=opts.relay_username+'@'+opts.relay_host
tmp_password, ok = QInputDialog.getText(self,
header,
_('Password:'),
mode=parent.relay_password.Password,
text=tmp_password)
if not ok:
tmp_password=''
else:
conf = smtp_prefs()
conf.set('relay_password', hexlify(str(tmp_password).encode('utf-8')))
tmp_password='password prompted'
else:
tmp_password=unhexlify(opts.relay_password).decode('utf-8')
self.label.setText(_('Using: %(un)s:%(pw)[email protected]%(host)s:%(port)s and %(enc)s encryption')%
dict(un=opts.relay_username, pw=tmp_password,
host=opts.relay_host, port=opts.relay_port, enc=opts.encryption))
示例2: word_dialog
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def word_dialog(self, msg):
response = QInputDialog.getText(self.top_level_window(), "Ledger Wallet Authentication", msg, QLineEdit.Password)
if not response[1]:
self.word = None
else:
self.word = str(response[0])
self.done.set()
示例3: debug_timing_test_pycode_from_a_dialog
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def debug_timing_test_pycode_from_a_dialog( ): #bruce 051117
# TODO: rewrite this to call grab_text_using_dialog (should be easy)
title = "debug: time python code"
label = "one line of python to compile and exec REPEATEDLY in debug.py's globals()\n(or use @@@ to fake \\n for more lines)"
from PyQt4.Qt import QInputDialog
parent = None
text, ok = QInputDialog.getText(parent, title, label) # parent argument needed only in Qt4 [bruce 070329, more info above]
if not ok:
print "time python code code: cancelled"
return
# fyi: type(text) == <class '__main__.qt.QString'>
command = str(text)
command = command.replace("@@@",'\n')
print "trying to time the exec or eval of command:",command
from code import compile_command
try:
try:
mycode = compile( command + '\n', '<string>', 'exec') #k might need '\n\n' or '' or to be adaptive in length?
# 'single' means print value if it's an expression and value is not None; for timing we don't want that so use 'eval'
# or 'exec' -- but we don't know which one is correct! So try exec, if that fails try eval.
print "exec" # this happens even for an expr like 2+2 -- why?
except SyntaxError:
print "try eval" # i didn't yet see this happen
mycode = compile_command( command + '\n', '<string>', 'eval')
except:
print_compact_traceback("exception in compile_command: ")
return
if mycode is None:
print "incomplete command:",command
return
# mycode is now a code object
print_exec_timing_explored(mycode)
示例4: edit_bookmark
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def edit_bookmark(self):
indexes = self.bookmarks_table.selectionModel().selectedIndexes()
if indexes != []:
title, ok = QInputDialog.getText(self, _('Edit bookmark'), _('New title for bookmark:'), QLineEdit.Normal, self._model.data(indexes[0], Qt.DisplayRole).toString())
title = QVariant(unicode(title).strip())
if ok and title:
self._model.setData(indexes[0], title, Qt.EditRole)
示例5: rename_requested
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def rename_requested(self, name, location):
loc = location.replace('/', os.sep)
base = os.path.dirname(loc)
newname, ok = QInputDialog.getText(self.gui, _('Rename') + ' ' + name,
'<p>'+_('Choose a new name for the library <b>%s</b>. ')%name +
'<p>'+_('Note that the actual library folder will be renamed.'),
text=name)
newname = sanitize_file_name_unicode(unicode(newname))
if not ok or not newname or newname == name:
return
newloc = os.path.join(base, newname)
if os.path.exists(newloc):
return error_dialog(self.gui, _('Already exists'),
_('The folder %s already exists. Delete it first.') %
newloc, show=True)
if (iswindows and len(newloc) >
LibraryDatabase2.WINDOWS_LIBRARY_PATH_LIMIT):
return error_dialog(self.gui, _('Too long'),
_('Path to library too long. Must be less than'
' %d characters.')%LibraryDatabase2.WINDOWS_LIBRARY_PATH_LIMIT,
show=True)
try:
os.rename(loc, newloc)
except:
import traceback
error_dialog(self.gui, _('Rename failed'),
_('Failed to rename the library at %s. '
'The most common cause for this is if one of the files'
' in the library is open in another program.') % loc,
det_msg=traceback.format_exc(), show=True)
return
self.stats.rename(location, newloc)
self.build_menus()
self.gui.iactions['Copy To Library'].build_menus()
示例6: auth_dialog
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def auth_dialog(self):
response = QInputDialog.getText(None, "Ledger Wallet Authentication", self.message, QLineEdit.Password)
if not response[1]:
self.response = None
else:
self.response = str(response[0])
self.done.set()
示例7: insert_link
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def insert_link(self, *args):
link, ok = QInputDialog.getText(self, _('Create link'),
_('Enter URL'))
if not ok:
return
url = self.parse_link(unicode(link))
if url.isValid():
url = unicode(url.toString())
self.exec_command('createLink', url)
示例8: create_folder
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def create_folder(self, item):
text, ok = QInputDialog.getText(self, _('Folder name'), _('Enter a name for the new folder'))
if ok and unicode(text):
c = QTreeWidgetItem(item, (unicode(text),))
c.setIcon(0, QIcon(I('mimetypes/dir.png')))
for item in self.folders.selectedItems():
item.setSelected(False)
c.setSelected(True)
self.folders.setCurrentItem(c)
示例9: match_all_above_thresh
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def match_all_above_thresh(fac, threshold=None):
'do matching and assign all above thresh'
if threshold == None:
# User ask
dlg = QInputDialog()
threshres = dlg.getText(None, 'Threshold Selector',
'Enter a matching threshold.\n'+
'The system will query each chip and assign all matches above this thresh')
if not threshres[1]:
logmsg('Cancelled all match')
return
try:
threshold = float(str(threshres[0]))
except ValueError:
logerr('The threshold must be a number')
qm = fac.hs.qm
cm = fac.hs.cm
nm = fac.hs.nm
vm = fac.hs.vm
# Get model ready
vm.sample_train_set()
fac.hs.ensure_model()
# Do all queries
for qcx in iter(cm.get_valid_cxs()):
qcid = cm.cx2_cid[qcx]
logmsg('Querying CID='+str(qcid))
query_name = cm.cx2_name(qcx)
logdbg(str(qcx))
logdbg(str(type(qcx)))
cm.load_features(qcx)
res = fac.hs.query(qcid)
# Match only those above a thresh
res.num_top_min = 0
res.num_extra_return = 0
res.top_thresh = threshold
top_cx = res.top_cx()
if len(top_cx) == 0:
print('No matched for cid='+str(qcid))
continue
top_names = cm.cx2_name(top_cx)
all_names = np.append(top_names,[query_name])
if all([nm.UNIDEN_NAME() == name for name in all_names]):
# If all names haven't been identified, make a new one
new_name = nm.get_new_name()
else:
# Rename to the most frequent non ____ name seen
from collections import Counter
name_freq = Counter(np.append(top_names,[query_name])).most_common()
new_name = name_freq[0][0]
if new_name == nm.UNIDEN_NAME():
new_name = name_freq[1][0]
# Do renaming
cm.rename_chip(qcx, new_name)
for cx in top_cx:
cm.rename_chip(cx, new_name)
fac.hs.uim.populate_tables()
示例10: create_checkpoint
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def create_checkpoint(self):
text, ok = QInputDialog.getText(
self.gui,
_("Choose name"),
_(
"Choose a name for the checkpoint.\nYou can later restore the book"
' to this checkpoint via the\n"Revert to..." entries in the Edit menu.'
),
)
if ok:
self.add_savepoint(text)
示例11: new_dictionary
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def new_dictionary(self):
name, ok = QInputDialog.getText(self, _('New dictionary'), _(
'Name of the new dictionary'))
if ok:
name = unicode(name)
if name in {d.name for d in dictionaries.all_user_dictionaries}:
return error_dialog(self, _('Already used'), _(
'A dictionary with the name %s already exists') % name, show=True)
dictionaries.create_user_dictionary(name)
self.dictionaries_changed = True
self.build_dictionaries(name)
self.show_current_dictionary()
示例12: save_theme
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def save_theme(self):
themename, ok = QInputDialog.getText(self, _('Theme name'),
_('Choose a name for this theme'))
if not ok: return
themename = unicode(themename).strip()
if not themename: return
c = config('')
c.add_opt('theme_name_xxx', default=themename)
self.save_options(c)
self.themes['theme_'+themename] = c.src
self.init_load_themes()
self.theming_message.setText(_('Saved settings as the theme named: %s')%
themename)
示例13: add_new_prop
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def add_new_prop(fac, propname=None):
'add a new property to keep track of'
if propname is None:
# User ask
dlg = QInputDialog()
textres = dlg.getText(None, 'New Metadata Property','What is the new property name? ')
if not textres[1]:
logmsg('Cancelled new property')
return
propname = str(textres[0])
logmsg('Adding property '+propname)
fac.hs.cm.add_user_prop(propname)
fac.hs.uim.populate_tables()
示例14: save_settings
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def save_settings(self):
xpaths = self.xpaths
if not xpaths:
return error_dialog(self, _('No XPaths'),
_('No XPaths have been entered'), show=True)
if not self.check():
return
name, ok = QInputDialog.getText(self, _('Choose name'),
_('Choose a name for these settings'))
if ok:
name = unicode(name).strip()
if name:
saved = gprefs.get('xpath_toc_settings', {})
saved[name] = {i:x for i, x in enumerate(xpaths)}
gprefs.set('xpath_toc_settings', saved)
self.setup_load_button()
示例15: makeNewList
# 需要导入模块: from PyQt4.Qt import QInputDialog [as 别名]
# 或者: from PyQt4.Qt.QInputDialog import getText [as 别名]
def makeNewList(self):
listName, okay = QInputDialog.getText(QInputDialog(), self.objectName().capitalize() + " List Name",
"New " + self.objectName().capitalize() + " List Name:",
QLineEdit.Normal, "New " + self.objectName().capitalize() + " List")
if okay and len(listName) > 0:
if any([listName in lst for lst in self._rddtDataExtractor.subredditLists]):
QMessageBox.information(QMessageBox(), "Data Extractor for reddit",
"Duplicate subreddit list names not allowed.")
return
self._lstChooser.addItem(listName)
self._lstChooser.setCurrentIndex(self._lstChooser.count() - 1)
self._chooserDict[listName] = ListModel([], self._classToUse)
self.chooseNewList(self._lstChooser.count() - 1)
if self._rddtDataExtractor.defaultSubredditListName is None: # becomes None if user deletes all subreddit lists
self._rddtDataExtractor.defaultSubredditListName = listName
self._gui.setUnsavedChanges(True)