本文整理汇总了Python中PyQt5.QtWidgets.QCompleter.setCaseSensitivity方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.setCaseSensitivity方法的具体用法?Python QCompleter.setCaseSensitivity怎么用?Python QCompleter.setCaseSensitivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QCompleter
的用法示例。
在下文中一共展示了QCompleter.setCaseSensitivity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _make_expression_completer
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def _make_expression_completer(owner, data_type):
model = QStringListModel()
comp = QCompleter(owner)
comp.setCaseSensitivity(Qt.CaseSensitive)
if isinstance(data_type, str):
data_type = uavcan.TYPENAMES[data_type]
# TODO: implement proper completion, requires Python lexer
# TODO: IPython/Jupyter solves the same task splendidly, might make sense to take a closer look at their code
def make_suggestions(t):
"""Builds a flat list of fields in a given data type"""
if t.category == t.CATEGORY_COMPOUND:
out = []
for a in t.fields + t.constants:
if (a.type.category != a.type.CATEGORY_COMPOUND) and \
(a.type.category != a.type.CATEGORY_VOID) and \
(a.type.category != a.type.CATEGORY_ARRAY or
a.type.value_type.category == a.type.value_type.CATEGORY_PRIMITIVE):
out.append(a.name)
out += [(a.name + x) for x in make_suggestions(a.type)]
return [('.' + x) for x in out]
elif t.category == t.CATEGORY_ARRAY:
base = '[0]'
if t.value_type.category == t.CATEGORY_COMPOUND:
return [(base + x) for x in make_suggestions(t.value_type)]
else:
return [base]
return []
suggestions = [(EXPRESSION_VARIABLE_FOR_MESSAGE + x) for x in make_suggestions(data_type)]
model.setStringList(suggestions)
comp.setModel(model)
return comp
示例2: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.createMenu()
self.completingTextEdit = TextEdit()
self.completer = QCompleter(self)
self.completer.setModel(self.modelFromFile(':/resources/wordlist.txt'))
self.completer.setModelSorting(QCompleter.CaseInsensitivelySortedModel)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setWrapAround(False)
self.completingTextEdit.setCompleter(self.completer)
self.setCentralWidget(self.completingTextEdit)
self.resize(500, 300)
self.setWindowTitle("Completer")
def createMenu(self):
exitAction = QAction("Exit", self)
aboutAct = QAction("About", self)
aboutQtAct = QAction("About Qt", self)
exitAction.triggered.connect(QApplication.instance().quit)
aboutAct.triggered.connect(self.about)
aboutQtAct.triggered.connect(QApplication.instance().aboutQt)
fileMenu = self.menuBar().addMenu("File")
fileMenu.addAction(exitAction)
helpMenu = self.menuBar().addMenu("About")
helpMenu.addAction(aboutAct)
helpMenu.addAction(aboutQtAct)
def modelFromFile(self, fileName):
f = QFile(fileName)
if not f.open(QFile.ReadOnly):
return QStringListModel(self.completer)
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
words = []
while not f.atEnd():
line = f.readLine().trimmed()
if line.length() != 0:
try:
line = str(line, encoding='ascii')
except TypeError:
line = str(line)
words.append(line)
QApplication.restoreOverrideCursor()
return QStringListModel(words, self.completer)
def about(self):
QMessageBox.about(self, "About",
"This example demonstrates the different features of the "
"QCompleter class.")
示例3: Completer
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
class Completer(QGraphicsProxyWidget, object):
''' Class for handling text autocompletion in the SDL scene '''
def __init__(self, parent):
''' Create an autocompletion list popup '''
widget = QListWidget()
super(Completer, self).__init__(parent)
self.setWidget(widget)
self.string_list = QStringListModel()
self._completer = QCompleter()
self.parent = parent
self._completer.setCaseSensitivity(Qt.CaseInsensitive)
# For some reason the default minimum size is (61,61)
# Set it to 0 so that the size of the box is not taken
# into account when it is hidden.
self.setMinimumSize(0, 0)
self.prepareGeometryChange()
self.resize(0, 0)
self.hide()
def set_completer_list(self):
''' Set list of items for the autocompleter popup '''
compl = [item.replace('-', '_') for item in
self.parent.parentItem().completion_list]
self.string_list.setStringList(compl)
self._completer.setModel(self.string_list)
def set_completion_prefix(self, completion_prefix):
'''
Set the current completion prefix (user-entered text)
and set the corresponding list of words in the popup widget
'''
self._completer.setCompletionPrefix(completion_prefix)
self.widget().clear()
count = self._completer.completionCount()
for i in xrange(count):
self._completer.setCurrentRow(i)
self.widget().addItem(self._completer.currentCompletion())
self.prepareGeometryChange()
if count:
self.resize(self.widget().sizeHintForColumn(0) + 40, 70)
else:
self.resize(0, 0)
return count
# pylint: disable=C0103
def keyPressEvent(self, e):
super(Completer, self).keyPressEvent(e)
if e.key() == Qt.Key_Escape:
self.parentItem().setFocus()
# Consume the event so that it is not repeated at EditableText level
e.accept()
# pylint: disable=C0103
def focusOutEvent(self, event):
''' When the user leaves the popup, return focus to parent '''
super(Completer, self).focusOutEvent(event)
self.hide()
self.resize(0, 0)
self.parentItem().setFocus()
示例4: return_tag_completer_TextEdit
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def return_tag_completer_TextEdit(parent=None):
ns = gallerydb.TagDB.get_all_ns()
for t in gallerydb.TagDB.get_all_tags():
ns.append(t)
TextEditCompleter = CompleterTextEdit()
comp = QCompleter(ns, parent)
comp.setCaseSensitivity(Qt.CaseInsensitive)
TextEditCompleter.setCompleter(comp)
return TextEditCompleter
示例5: __init__
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def __init__(self, parent, completion_model=None):
super(SearchBarComboBox, self).__init__(parent)
self.setFont(get_monospace_font())
self.setToolTip('Enter the search pattern here')
completer = QCompleter(self)
completer.setCaseSensitivity(Qt.CaseSensitive)
if completion_model is not None:
completer.setModel(completion_model)
else:
completer.setModel(self.model())
self.setCompleter(completer)
示例6: __init__
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def __init__(self,expdat):
super(DBAnnotateSave, self).__init__()
print("DBAnnotateSave")
uic.loadUi(os.path.join(hs.heatsequerdir,'ui/manualdata.py'), self)
self.bplus.clicked.connect(self.plus)
self.bminus.clicked.connect(self.minus)
self.bontoinput.returnPressed.connect(self.plus)
self.bstudyinfo.clicked.connect(self.studyinfo)
self.bisa.toggled.connect(self.radiotoggle)
self.bdiffpres.toggled.connect(self.radiotoggle)
self.bisatype.currentIndexChanged.connect(self.isatypechanged)
self.bhistory.clicked.connect(self.history)
self.cexp=expdat
self.lnumbact.setText(str(len(expdat.selectedseqs)))
completer = QCompleter()
self.bontoinput.setCompleter(completer)
scdb=hs.scdb
self.scdb=scdb
self.dataid=hs.supercooldb.finddataid(scdb,datamd5=self.cexp.datamd5,mapmd5=self.cexp.mapmd5)
model = QStringListModel()
completer.setModel(model)
# completer.setCompletionMode(QCompleter.InlineCompletion)
completer.maxVisibleItems=10
completer.setCaseSensitivity(Qt.CaseInsensitive)
# make the completer selection also erase the text edit
completer.activated.connect(self.cleartext,type=Qt.QueuedConnection)
# in qt5 should work with middle complete as well...
# completer.setFilterMode(Qt.MatchContains)
if not hs.scdb.ontologyfromid:
hs.scdb=hs.supercooldb.loaddbonto(hs.scdb)
self.ontology=hs.scdb.ontology
self.ontologyfromid=hs.scdb.ontologyfromid
nlist=list(self.ontology.keys())
# nlist=sorted(nlist)
nlist=sorted(nlist, key=lambda s: s.lower())
print("sorted ontology")
model.setStringList(nlist)
self.setWindowTitle(self.cexp.studyname)
try:
tt=hs.lastdatamd5
except:
hs.lastdatamd5=''
if self.cexp.datamd5==hs.lastdatamd5:
self.fillfromcuration(hs.lastcurations[-1],onlyall=True)
self.prefillinfo()
self.bontoinput.setFocus()
示例7: createEditor
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def createEditor(self, manager, property, parent):
type = manager.propertyType(property)
if (type == VariantPropertyManager.filePathTypeId()):
editor = FileEdit(parent)
editor.setFilePath(manager.value(property))
editor.setFilter(manager.attributeValue(property, "filter"))
self.mCreatedEditors[property].append(editor)
self.mEditorToProperty[editor] = property
editor.filePathChanged.connect(self.slotSetValue)
editor.destroyed.connect(self.slotEditorDestroyed)
return editor
editor = super().createEditor(manager, property, parent)
if (type == QVariant.String):
# Add support for "suggestions" attribute that adds a QCompleter to the QLineEdit
suggestions = manager.attributeValue(property, "suggestions")
if suggestions and len(suggestions)>0:
lineEdit = editor
if lineEdit:
completer = QCompleter(suggestions, lineEdit)
completer.setCaseSensitivity(Qt.CaseInsensitive)
lineEdit.setCompleter(completer)
return editor
示例8: CLIWidget
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
class CLIWidget(QWidget):
def __init__(self, parent, cli_iface):
super(CLIWidget, self).__init__(parent)
self._cli_iface = cli_iface
self._command_line = CommitableComboBoxWithHistory(self)
self._command_line.setToolTip('Enter the command here')
self._command_line.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self._command_line.setFont(get_monospace_font())
self._command_line.on_commit = self._do_execute
self._command_line_completer = QCompleter()
self._command_line_completer.setCaseSensitivity(Qt.CaseSensitive)
self._command_line_completer.setModel(self._command_line.model())
self._command_line.setCompleter(self._command_line_completer)
self._execute_button = make_icon_button('flash', 'Execute command', self, on_clicked=self._do_execute)
self._response_box = QPlainTextEdit(self)
self._response_box.setToolTip('Command output will be printed here')
self._response_box.setReadOnly(True)
self._response_box.setLineWrapMode(QPlainTextEdit.NoWrap)
self._response_box.setFont(get_monospace_font())
self._response_box.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
try:
self._log_viewer.setPlaceholderText('Command output will be printed here')
except AttributeError: # Old PyQt
pass
layout = QVBoxLayout(self)
controls_layout = QHBoxLayout(self)
controls_layout.addWidget(self._command_line, 1)
controls_layout.addWidget(self._execute_button)
layout.addLayout(controls_layout)
layout.addWidget(self._response_box, 1)
self.setLayout(layout)
def _do_execute(self):
self._response_box.clear()
command = self._command_line.currentText()
if not command.strip():
return
self._command_line.add_current_text_to_history()
def callback(lines):
self.setEnabled(True)
if lines is None:
self.window().show_message('Command response timed out')
self._response_box.setPlainText('<RESPONSE TIMED OUT>')
else:
self.window().show_message('Command response received')
self._response_box.setPlainText(lines)
self.setEnabled(False)
self._cli_iface.execute_raw_command(command, callback)
示例9: init_toolbar
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
#.........这里部分代码省略.........
self.grid_toggle.setIcon(self.grid_toggle_g_icon)
self.grid_toggle.setObjectName('gridtoggle')
self.grid_toggle.clicked.connect(self.toggle_view)
self.toolbar.addWidget(self.grid_toggle)
spacer_mid2 = QWidget()
spacer_mid2.setFixedSize(QSize(5, 1))
self.toolbar.addWidget(spacer_mid2)
def set_search_case(b):
app_constants.GALLERY_SEARCH_CASE = b
settings.set(b, 'Application', 'gallery search case')
settings.save()
def set_search_strict(b):
app_constants.GALLERY_SEARCH_STRICT = b
settings.set(b, 'Application', 'gallery search strict')
settings.save()
self.search_bar = misc.LineEdit()
search_options = self.search_bar.addAction(QIcon(app_constants.SEARCH_OPTIONS_PATH), QLineEdit.TrailingPosition)
search_options_menu = QMenu(self)
search_options.triggered.connect(lambda: search_options_menu.popup(QCursor.pos()))
search_options.setMenu(search_options_menu)
case_search_option = search_options_menu.addAction('Case Sensitive')
case_search_option.setCheckable(True)
case_search_option.setChecked(app_constants.GALLERY_SEARCH_CASE)
case_search_option.toggled.connect(set_search_case)
strict_search_option = search_options_menu.addAction('Match whole terms')
strict_search_option.setCheckable(True)
strict_search_option.setChecked(app_constants.GALLERY_SEARCH_STRICT)
strict_search_option.toggled.connect(set_search_strict)
self.search_bar.setObjectName('search_bar')
self.search_timer = QTimer(self)
self.search_timer.setSingleShot(True)
self.search_timer.timeout.connect(lambda: self.search(self.search_bar.text()))
self._search_cursor_pos = [0, 0]
def set_cursor_pos(old, new):
self._search_cursor_pos[0] = old
self._search_cursor_pos[1] = new
self.search_bar.cursorPositionChanged.connect(set_cursor_pos)
if app_constants.SEARCH_AUTOCOMPLETE:
completer = QCompleter(self)
completer_view = misc.CompleterPopupView()
completer.setPopup(completer_view)
completer_view._setup()
completer.setModel(self.manga_list_view.gallery_model)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setCompletionMode(QCompleter.PopupCompletion)
completer.setCompletionRole(Qt.DisplayRole)
completer.setCompletionColumn(app_constants.TITLE)
completer.setFilterMode(Qt.MatchContains)
self.search_bar.setCompleter(completer)
self.search_bar.returnPressed.connect(lambda: self.search(self.search_bar.text()))
if not app_constants.SEARCH_ON_ENTER:
self.search_bar.textEdited.connect(lambda: self.search_timer.start(800))
self.search_bar.setPlaceholderText("Search title, artist, namespace & tags")
self.search_bar.setMinimumWidth(150)
self.search_bar.setMaximumWidth(500)
self.search_bar.setFixedHeight(19)
self.manga_list_view.sort_model.HISTORY_SEARCH_TERM.connect(lambda a: self.search_bar.setText(a))
self.toolbar.addWidget(self.search_bar)
def search_history(_, back=True): # clicked signal passes a bool
sort_model = self.manga_list_view.sort_model
nav = sort_model.PREV if back else sort_model.NEXT
history_term = sort_model.navigate_history(nav)
if back:
self.search_forward.setVisible(True)
back = QShortcut(QKeySequence(QKeySequence.Back), self, lambda: search_history(None))
forward = QShortcut(QKeySequence(QKeySequence.Forward), self, lambda: search_history(None, False))
search_backbutton = QToolButton(self.toolbar)
search_backbutton.setText(u'\u25C0')
search_backbutton.setFixedWidth(15)
search_backbutton.clicked.connect(search_history)
self.search_backward = self.toolbar.addWidget(search_backbutton)
self.search_backward.setVisible(False)
search_forwardbutton = QToolButton(self.toolbar)
search_forwardbutton.setText(u'\u25B6')
search_forwardbutton.setFixedWidth(15)
search_forwardbutton.clicked.connect(lambda: search_history(None, False))
self.search_forward = self.toolbar.addWidget(search_forwardbutton)
self.search_forward.setVisible(False)
spacer_end = QWidget() # aligns settings action properly
spacer_end.setFixedSize(QSize(10, 1))
self.toolbar.addWidget(spacer_end)
settings_act = QToolButton(self.toolbar)
settings_act.setIcon(QIcon(app_constants.SETTINGS_PATH))
settings_act.clicked.connect(self.settings)
self.toolbar.addWidget(settings_act)
spacer_end2 = QWidget() # aligns About action properly
spacer_end2.setFixedSize(QSize(5, 1))
self.toolbar.addWidget(spacer_end2)
self.addToolBar(self.toolbar)
示例10: MainWidget
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
#.........这里部分代码省略.........
self.initializeStatusUpdater()
self.statusChanged()
self._selectedGroups = []
self.packageList.select_all.setChecked(False)
self.initializeBasket()
self.searchLine.setFocus(True)
if self.currentState == self.state.UPGRADE:
if self.groupList.count() == 0:
QTimer.singleShot(0, \
lambda: self.pdsMessageBox.showMessage(_translate("Packaga Manager","All packages are up to date"), icon = "info"))
if self.groupList.count() > 0:
if self.state.inUpgrade():
self.pdsMessageBox.hideMessage(force = True)
restoreCursor()
def initializeStatusUpdater(self):
self.statusUpdater.calculate_deps = not self.state.state == self.state.ALL
self.statusUpdater.setModel(self.packageList.model().sourceModel())
def initializeBasket(self):
waitCursor()
self.basket.setModel(self.packageList.model().sourceModel())
restoreCursor()
def initializePackageList(self):
self.packageList.model().reset()
self.packageList.setPackages(self.state.packages())
if self.completer:
self.completer.deleteLater()
del self.completer
self.completer = QCompleter(self.state.allPackages(), self)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.searchLine.setCompleter(self.completer)
def selectComponent(self, component):
if not self.state.iface.operationInProgress():
if self.basket.isVisible():
self.basket._hide()
self.stateTab.setCurrentIndex(1)
self.switchState(self.state.INSTALL)
if component in self.groupList._list:
self.groupList.setCurrentItem(self.groupList._list[component])
self.groupFilter()
def updateSettings(self): # pmconfig ikinci kez okunmuyor
self.packageList.showComponents = PMConfig().showComponents()
self.packageList.showIsA = PMConfig().showIsA()
self.packageList.setFocus()
self.initialize()
def searchLineChanged(self, text):
self.searchButton.setEnabled(bool(text))
if text == '':
self.searchActivated()
def statusUpdated(self):
if self.statusUpdater.needsUpdate:
self.statusUpdater.needsUpdate = False
self.statusChanged()
def statusChanged(self):
self.setActionEnabled()
示例11: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
#.........这里部分代码省略.........
self.keep_debug = QCheckBox("Keep debug info on compile for GDB")
self.traced = QCheckBox("Traced execution output")
self.plusplus = QCheckBox("Compile C++ Only on generated source files")
self.experimental = QCheckBox("Experimental features")
self.force_clang = QCheckBox("Force use of CLang")
self.force_mingw = QCheckBox("Force use of MinGW on MS Windows")
self.force_lto = QCheckBox("Use link time optimizations LTO")
self.show_scons = QCheckBox("Show Scons executed commands")
self.show_progress = QCheckBox("Show progress info and statistics")
self.show_summary = QCheckBox("Show final summary of included modules")
self.disable_console = QCheckBox("Disable the Console on MS Windows")
for i, widget in enumerate((
self.module, self.standalone, self.nofreeze, self.python_debug,
self.warning, self.recurse_std, self.recurse_not, self.execute,
self.pythonpath, self.enhaced, self.nolineno, self.rmbuilddir,
self.nuitka_debug, self.keep_debug, self.traced, self.plusplus,
self.experimental, self.force_clang, self.force_mingw,
self.force_lto, self.show_scons, self.show_progress,
self.show_summary, self.disable_console)):
widget.setToolTip(widget.text())
g0grid.addWidget(widget, i if i < i + 1 else i - (i - 1), i % 2)
# group 1 paths
self.target = QLineEdit()
self.outdir = QLineEdit(os.path.expanduser("~"))
self.t_icon = QLineEdit()
self.target.setToolTip("Python App file you want to Compile to Binary")
self.outdir.setToolTip("Folder to write Compiled Output Binary files")
self.t_icon.setToolTip("Icon image file to embed for your Python App")
self.target.setPlaceholderText("/full/path/to/target/python_app.py")
self.outdir.setPlaceholderText("/full/path/to/output/folder/")
self.t_icon.setPlaceholderText("/full/path/to/python_app/icon.png")
self.completer, self.dirs = QCompleter(self), QDirModel(self)
self.completer.setModel(self.dirs)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setCompletionMode(QCompleter.PopupCompletion)
self.completer.popup().setStyleSheet("border: 1px solid gray")
self.completer.popup().setVerticalScrollBarPolicy(
Qt.ScrollBarAlwaysOff)
self.outdir.setCompleter(self.completer)
self.t_icon.setCompleter(self.completer)
self.target.setCompleter(self.completer)
self.clear_1 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.target.clear())
self.clear_2 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.t_icon.clear())
self.clear_3 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.outdir.clear())
self.open_1 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.target.setText(str(QFileDialog.getOpenFileName(
self, __doc__, os.path.expanduser("~"), """Python (*.py);;
Python for Windows (*.pyw);;All (*.*)""")[0])))
self.open_2 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.t_icon.setText(str(QFileDialog.getOpenFileName(
self, __doc__, os.path.expanduser("~"),
"PNG (*.png);;JPG (*.jpg);;ICO (*.ico);;All (*.*)")[0])))
self.open_3 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.outdir.setText(str(QFileDialog.getExistingDirectory(
self, __doc__, os.path.expanduser("~")))))
self.l_icon = QLabel("Target Icon")
g1vlay.addWidget(QLabel("<b>Target Python"), 0, 0)
g1vlay.addWidget(self.target, 0, 1)
g1vlay.addWidget(self.clear_1, 0, 2)
g1vlay.addWidget(self.open_1, 0, 3)
示例12: __init__
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def __init__(self, parent):
super(ProjectExecution, self).__init__()
self._parent = parent
grid = QGridLayout(self)
grid.addWidget(QLabel(translations.TR_PROJECT_MAIN_FILE), 0, 0)
# Main file
self.path = QLineEdit()
choose_main_file_action = QAction(self)
choose_main_file_action.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
choose_main_file_action.setToolTip(
translations.TR_PROJECT_SELECT_MAIN_FILE)
self.path.addAction(
choose_main_file_action, QLineEdit.TrailingPosition)
clear_main_file_action = self.path.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_main_file_action.triggered.connect(self.path.clear)
self.path.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'main.py'))
self.path.setText(self._parent.project.main_file)
grid.addWidget(self.path, 0, 1)
# this should be changed, and ALL pythonPath names to
# python_custom_interpreter or something like that. this is NOT the
# PYTHONPATH
self.line_interpreter = QLineEdit()
choose_interpreter = self.line_interpreter.addAction(
self.style().standardIcon(self.style().SP_DirIcon),
QLineEdit.TrailingPosition)
self.line_interpreter.setText(self._parent.project.python_exec)
completer = QCompleter(utils.get_python())
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setFilterMode(Qt.MatchContains)
self.line_interpreter.setCompleter(completer)
self.line_interpreter.setPlaceholderText("python")
grid.addWidget(QLabel(
translations.TR_PROJECT_PYTHON_INTERPRETER), 1, 0)
grid.addWidget(self.line_interpreter, 1, 1)
# PYTHONPATH
grid.addWidget(QLabel(translations.TR_PROJECT_PYTHON_PATH), 2, 0)
self.txt_python_path = QPlainTextEdit() # TODO : better widget
self.txt_python_path.setPlainText(self._parent.project.python_path)
self.txt_python_path.setToolTip(translations.TR_PROJECT_PATH_PER_LINE)
grid.addWidget(self.txt_python_path, 2, 1)
# Additional builtins/globals for pyflakes
grid.addWidget(QLabel(translations.TR_PROJECT_BUILTINS), 3, 0)
self.additional_builtins = QLineEdit()
self.additional_builtins.setText(
' '.join(self._parent.project.additional_builtins))
self.additional_builtins.setToolTip(
translations.TR_PROJECT_BUILTINS_TOOLTIP)
grid.addWidget(self.additional_builtins, 3, 1)
# Pre script
self._line_pre_exec = QLineEdit()
choose_pre_exec = QAction(self)
choose_pre_exec.setToolTip(
"Choose Script to execute before run project")
choose_pre_exec.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
self._line_pre_exec.addAction(
choose_pre_exec, QLineEdit.TrailingPosition)
clear_pre_action = self._line_pre_exec.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_pre_action.triggered.connect(self._line_pre_exec.clear)
self._line_pre_exec.setReadOnly(True)
self._line_pre_exec.setText(self._parent.project.pre_exec_script)
self._line_pre_exec.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh'))
grid.addWidget(QLabel(translations.TR_PROJECT_PRE_EXEC), 4, 0)
grid.addWidget(self._line_pre_exec, 4, 1)
# Post script
self._line_post_exec = QLineEdit()
choose_post_exec = QAction(self)
choose_post_exec.setToolTip(
"Choose script to execute after run project")
choose_post_exec.setIcon(
self.style().standardIcon(self.style().SP_FileIcon))
self._line_post_exec.addAction(
choose_post_exec, QLineEdit.TrailingPosition)
clear_post_action = self._line_post_exec.addAction(
self.style().standardIcon(self.style().SP_LineEditClearButton),
QLineEdit.TrailingPosition)
clear_post_action.triggered.connect(self._line_post_exec.clear)
self._line_post_exec.setReadOnly(True)
self._line_post_exec.setText(self._parent.project.post_exec_script)
self._line_post_exec.setPlaceholderText(
os.path.join(os.path.expanduser("~"), 'path', 'to', 'script.sh'))
grid.addWidget(QLabel(translations.TR_PROJECT_POST_EXEC), 5, 0)
grid.addWidget(self._line_post_exec, 5, 1)
# grid.addItem(QSpacerItem(5, 10, QSizePolicy.Expanding,
# QSizePolicy.Expanding), 6, 0)
# Properties
grid.addWidget(QLabel(translations.TR_PROJECT_PROPERTIES), 7, 0)
self._line_params = QLineEdit()
self._line_params.setToolTip(translations.TR_PROJECT_PARAMS_TOOLTIP)
#.........这里部分代码省略.........
示例13: run_iface_config_window
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def run_iface_config_window(icon):
win = QDialog()
win.setWindowTitle('CAN Interface Configuration')
win.setWindowIcon(icon)
win.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
win.setAttribute(Qt.WA_DeleteOnClose) # This is required to stop background timers!
combo = QComboBox(win)
combo.setEditable(True)
combo.setInsertPolicy(QComboBox.NoInsert)
combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
combo.setFont(get_monospace_font())
combo_completer = QCompleter()
combo_completer.setCaseSensitivity(Qt.CaseSensitive)
combo_completer.setModel(combo.model())
combo.setCompleter(combo_completer)
bitrate = QSpinBox(win)
bitrate.setMaximum(1000000)
bitrate.setMinimum(10000)
bitrate.setValue(1000000)
baudrate = QComboBox(win)
baudrate.setEditable(True)
baudrate.setInsertPolicy(QComboBox.NoInsert)
baudrate.setSizeAdjustPolicy(QComboBox.AdjustToContents)
baudrate.setFont(get_monospace_font())
baudrate_completer = QCompleter(win)
baudrate_completer.setModel(baudrate.model())
baudrate.setCompleter(baudrate_completer)
baudrate.setValidator(QIntValidator(min(STANDARD_BAUD_RATES), max(STANDARD_BAUD_RATES)))
baudrate.insertItems(0, map(str, STANDARD_BAUD_RATES))
baudrate.setCurrentText(str(DEFAULT_BAUD_RATE))
ok = QPushButton('OK', win)
def update_slcan_options_visibility():
if RUNNING_ON_LINUX:
slcan_active = '/' in combo.currentText()
else:
slcan_active = True
slcan_group.setEnabled(slcan_active)
combo.currentTextChanged.connect(update_slcan_options_visibility)
ifaces = None
def update_iface_list():
nonlocal ifaces
ifaces = iface_lister.get_list()
known_keys = set()
remove_indices = []
was_empty = combo.count() == 0
# Marking known and scheduling for removal
for idx in count():
tx = combo.itemText(idx)
if not tx:
break
known_keys.add(tx)
if tx not in ifaces:
logger.debug('Removing iface %r', tx)
remove_indices.append(idx)
# Removing - starting from the last item in order to retain indexes
for idx in remove_indices[::-1]:
combo.removeItem(idx)
# Adding new items - starting from the last item in order to retain the final order
for key in list(ifaces.keys())[::-1]:
if key not in known_keys:
logger.debug('Adding iface %r', key)
combo.insertItem(0, key)
# Updating selection
if was_empty:
combo.setCurrentIndex(0)
result = None
kwargs = {}
def on_ok():
nonlocal result, kwargs
try:
baud_rate_value = int(baudrate.currentText())
except ValueError:
show_error('Invalid parameters', 'Could not parse baud rate', 'Please specify correct baud rate',
parent=win)
return
if not (min(STANDARD_BAUD_RATES) <= baud_rate_value <= max(STANDARD_BAUD_RATES)):
show_error('Invalid parameters', 'Baud rate is out of range',
'Baud rate value should be within [%s, %s]' %
(min(STANDARD_BAUD_RATES), max(STANDARD_BAUD_RATES)),
parent=win)
return
kwargs['baudrate'] = baud_rate_value
kwargs['bitrate'] = int(bitrate.value())
result_key = str(combo.currentText()).strip()
if not result_key:
show_error('Invalid parameters', 'Interface name cannot be empty', 'Please select a valid interface',
parent=win)
#.........这里部分代码省略.........
示例14: init_toolbar
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def init_toolbar(self):
self.toolbar = QToolBar()
self.toolbar.setFixedHeight(25)
self.toolbar.setWindowTitle("Show") # text for the contextmenu
# self.toolbar.setStyleSheet("QToolBar {border:0px}") # make it user defined?
self.toolbar.setMovable(False)
self.toolbar.setFloatable(False)
# self.toolbar.setIconSize(QSize(20,20))
self.toolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
spacer_start = QWidget() # aligns the first actions properly
spacer_start.setFixedSize(QSize(10, 1))
self.toolbar.addWidget(spacer_start)
favourite_view_icon = QIcon(gui_constants.STAR_BTN_PATH)
favourite_view_action = QAction(favourite_view_icon, "Favorites", self)
favourite_view_action.setToolTip("Show only favourite galleries")
favourite_view_action.triggered.connect(self.favourite_display) # need lambda to pass extra args
self.toolbar.addAction(favourite_view_action)
catalog_view_icon = QIcon(gui_constants.HOME_BTN_PATH)
catalog_view_action = QAction(catalog_view_icon, "Library", self)
catalog_view_action.setToolTip("Show all your galleries")
# catalog_view_action.setText("Catalog")
catalog_view_action.triggered.connect(self.catalog_display) # need lambda to pass extra args
self.toolbar.addAction(catalog_view_action)
self.toolbar.addSeparator()
gallery_menu = QMenu()
gallery_action = QToolButton()
gallery_action.setText("Gallery ")
gallery_action.setPopupMode(QToolButton.InstantPopup)
gallery_action.setToolTip("Contains various gallery related features")
gallery_action.setMenu(gallery_menu)
add_gallery_icon = QIcon(gui_constants.PLUS_PATH)
gallery_action_add = QAction(add_gallery_icon, "Add gallery", self)
gallery_action_add.triggered.connect(self.manga_list_view.SERIES_DIALOG.emit)
gallery_action_add.setToolTip("Add a single gallery thoroughly")
gallery_menu.addAction(gallery_action_add)
add_more_action = QAction(add_gallery_icon, "Add galleries...", self)
add_more_action.setStatusTip("Add galleries from different folders")
add_more_action.triggered.connect(lambda: self.populate(True))
gallery_menu.addAction(add_more_action)
populate_action = QAction(add_gallery_icon, "Populate from folder...", self)
populate_action.setStatusTip("Populates the DB with galleries from a single folder")
populate_action.triggered.connect(self.populate)
gallery_menu.addAction(populate_action)
gallery_menu.addSeparator()
metadata_action = QAction("Get metadata for all galleries", self)
metadata_action.triggered.connect(self.get_metadata)
gallery_menu.addAction(metadata_action)
self.toolbar.addWidget(gallery_action)
self.toolbar.addSeparator()
misc_action = QToolButton()
misc_action.setText("Misc ")
misc_action_menu = QMenu()
misc_action.setMenu(misc_action_menu)
misc_action.setPopupMode(QToolButton.InstantPopup)
misc_action.setToolTip("Contains misc. features")
misc_action_random = QAction("Open random gallery", misc_action_menu)
misc_action_random.triggered.connect(self.manga_list_view.open_random_gallery)
misc_action_menu.addAction(misc_action_random)
duplicate_check_simple = QAction("Simple duplicate finder", misc_action_menu)
duplicate_check_simple.triggered.connect(lambda: self.manga_list_view.duplicate_check())
misc_action_menu.addAction(duplicate_check_simple)
self.toolbar.addWidget(misc_action)
spacer_middle = QWidget() # aligns buttons to the right
spacer_middle.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.toolbar.addWidget(spacer_middle)
self.grid_toggle_g_icon = QIcon(gui_constants.GRID_PATH)
self.grid_toggle_l_icon = QIcon(gui_constants.LIST_PATH)
self.grid_toggle = QToolButton()
if self.display.currentIndex() == self.m_l_view_index:
self.grid_toggle.setIcon(self.grid_toggle_l_icon)
else:
self.grid_toggle.setIcon(self.grid_toggle_g_icon)
self.grid_toggle.setObjectName("gridtoggle")
self.grid_toggle.clicked.connect(self.toggle_view)
self.toolbar.addWidget(self.grid_toggle)
self.search_bar = misc.LineEdit()
if gui_constants.SEARCH_AUTOCOMPLETE:
completer = QCompleter(self)
completer.setModel(self.manga_list_view.gallery_model)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setCompletionMode(QCompleter.PopupCompletion)
completer.setCompletionRole(Qt.DisplayRole)
completer.setCompletionColumn(gui_constants.TITLE)
completer.setFilterMode(Qt.MatchContains)
self.search_bar.setCompleter(completer)
if gui_constants.SEARCH_ON_ENTER:
self.search_bar.returnPressed.connect(lambda: self.search(self.search_bar.text()))
else:
self.search_bar.textChanged[str].connect(self.search)
self.search_bar.setPlaceholderText("Search title, artist, namespace & tags")
self.search_bar.setMinimumWidth(150)
self.search_bar.setMaximumWidth(500)
#.........这里部分代码省略.........
示例15: run_iface_config_window
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCaseSensitivity [as 别名]
def run_iface_config_window(icon):
ifaces = list_ifaces()
win = QDialog()
win.setWindowTitle('CAN Interface Configuration')
win.setWindowIcon(icon)
win.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
combo = QComboBox(win)
combo.setEditable(True)
combo.setInsertPolicy(QComboBox.NoInsert)
combo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
combo.addItems(ifaces.keys())
combo_completer = QCompleter()
combo_completer.setCaseSensitivity(Qt.CaseSensitive)
combo_completer.setModel(combo.model())
combo.setCompleter(combo_completer)
bitrate = QSpinBox()
bitrate.setMaximum(1000000)
bitrate.setMinimum(10000)
bitrate.setValue(1000000)
extra_args = QLineEdit()
extra_args.setFont(get_monospace_font())
ok = QPushButton('OK', win)
result = None
kwargs = {}
def on_ok():
nonlocal result, kwargs
a = str(extra_args.text())
if a:
try:
kwargs = dict(eval(a))
except Exception as ex:
show_error('Invalid parameters', 'Could not parse optional arguments', ex, parent=win)
return
kwargs['bitrate'] = int(bitrate.value())
result_key = str(combo.currentText()).strip()
try:
result = ifaces[result_key]
except KeyError:
result = result_key
win.close()
ok.clicked.connect(on_ok)
layout = QVBoxLayout()
layout.addWidget(QLabel('Select CAN interface or serial port for SLCAN:'))
layout.addWidget(combo)
layout.addWidget(QLabel('Interface bitrate (SLCAN only):'))
layout.addWidget(bitrate)
layout.addWidget(QLabel('Optional arguments (refer to Pyuavcan for info):'))
layout.addWidget(extra_args)
layout.addWidget(ok)
layout.setSizeConstraint(layout.SetFixedSize)
win.setLayout(layout)
win.exec()
return result, kwargs