本文整理汇总了Python中PySide.QtGui.QCompleter.setCaseSensitivity方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.setCaseSensitivity方法的具体用法?Python QCompleter.setCaseSensitivity怎么用?Python QCompleter.setCaseSensitivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QCompleter
的用法示例。
在下文中一共展示了QCompleter.setCaseSensitivity方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __create_filter_ui
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def __create_filter_ui(self):
""" Create filter widgets """
filter_layout = QHBoxLayout()
filter_layout.setSpacing(1)
filter_layout.setContentsMargins(0, 0, 0, 0)
self.filter_reset_btn = QPushButton()
icon = QIcon(':/filtersOff.png')
self.filter_reset_btn.setIcon(icon)
self.filter_reset_btn.setIconSize(QSize(22, 22))
self.filter_reset_btn.setFixedSize(24, 24)
self.filter_reset_btn.setToolTip('Reset filter')
self.filter_reset_btn.setFlat(True)
self.filter_reset_btn.clicked.connect(
partial(self.on_filter_set_text, ''))
self.filter_line = QLineEdit()
self.filter_line.setPlaceholderText('Enter filter string here')
self.filter_line.textChanged.connect(self.on_filter_change_text)
completer = QCompleter(self)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.setModel(QStringListModel([], self))
self.filter_line.setCompleter(completer)
filter_layout.addWidget(self.filter_reset_btn)
filter_layout.addWidget(self.filter_line)
return filter_layout
示例2: __init__
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def __init__(self, history, commands):
self.history = history
self.reset_history()
super(CommandBox, self).__init__()
completer = QCompleter(['!' + name for name in commands])
completer.setCaseSensitivity(Qt.CaseInsensitive)
self.setCompleter(completer)
示例3: Completer
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.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: RuleTextEdit
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
class RuleTextEdit(QLineEdit):
_valid = True
_rule = None
completer = None
def __init__(self, *args, **kwargs):
super(RuleTextEdit, self).__init__(*args, **kwargs)
self.setAutoFillBackground(True)
self.textChanged.connect(self.onTextChange)
model = QStringListModel()
model.setStringList(['<', '>', '=', 'vasya'])
self.completer = QCompleter(model)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.setCompleter(self.completer)
@property
def rule(self):
return self._rule
@rule.setter
def rule(self, value):
self._rule = value
self.gen_rule()
def regen_rule(self):
text = self.text()
m = re.search('\\b(.)([<>=])(\d+)\\b', text)
self._valid = False
if m:
shear = 1 if m.group(2) == '>' else -1 if m.group(2) == '<' else 0
self._rule.new_symbol = str(m.group(1))
self._rule.shear = shear
self._rule.next_state = int(m.group(3))
self._valid = True
palette = self.palette()
assert (isinstance(palette, QPalette))
clr = QColor(255, 255, 128) if self._valid else QColor(255, 128, 128)
palette.setColor(self.backgroundRole(), clr)
self.setPalette(palette)
def onTextChange(self):
self.regen_rule()
def gen_rule(self):
if not self._rule:
return
self.setText('{0}{1}{2}'.format(
self._rule.new_symbol,
'<' if self._rule.shear == -1 else '>' if self._rule.shear == 1 else '=',
self._rule.next_state)
)
self._valid = True
示例5: config_completer
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def config_completer(line_edit, model, field):
# sets up a completer based on a QSqlTableModel for the specified field on a QLineEdit
completer = QCompleter()
completer.setModel(model)
completer.setCompletionColumn(model.fieldIndex(field))
completer.setCompletionMode(QCompleter.PopupCompletion)
completer.setCaseSensitivity(Qt.CaseInsensitive)
completer.activated.connect(line_edit.returnPressed)
line_edit.setCompleter(completer)
示例6: configure_search_lineedit
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def configure_search_lineedit(self, lineEdit):
if not self._configured: # no data received yet. hold on configuration
self._search_lineedit = lineEdit
else:
splitter = lineEdit.column_query_splitter
completer = QCompleter([header+splitter for header in self._headers[1:]]) # search anything but the image column
completer.setCaseSensitivity(Qt.CaseInsensitive)
lineEdit.setCompleter(completer)
lineEdit.textEdited.connect(self.query)
self._column_query_sep = splitter
示例7: _createApiChooserLineedit
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def _createApiChooserLineedit(self):
"""
Create the I{QLineEdit }used for selecting API names. This includes a QCompleter to make suggestions based on
the keyword database.
"""
self.api_chooser_lineedit = QLineEdit()
self.api_chooser_lineedit.returnPressed.connect(self.populateBrowserWindow)
self.api_chooser_lineedit.textChanged.connect(self._updateCompleterModel)
completer = QCompleter()
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
completer.setModelSorting(QCompleter.CaseSensitivelySortedModel)
self.completer_model = QStringListModel([])
completer.setModel(self.completer_model)
self.api_chooser_lineedit.setCompleter(completer)
示例8: CommandBox
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
class CommandBox(QtGui.QPlainTextEdit, object):
newCommand = QtCore.Signal(str)
def reset_history(self):
self.history_index = len(self.history)
def __init__(self, history, commands):
self.history_index = 0
self.history = history
self.reset_history()
super(CommandBox, self).__init__()
#Autocompleter
self.completer = QCompleter([BOT_PREFIX + name for name in commands], self)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setWidget(self)
self.completer.activated.connect(self.onAutoComplete)
self.autocompleteStart = None
def onAutoComplete(self, text):
#Select the text from autocompleteStart until the current cursor
cursor = self.textCursor()
cursor.setPosition(0, cursor.KeepAnchor)
#Replace it with the selected text
cursor.insertText(text)
self.autocompleteStart = None
#noinspection PyStringFormat
def keyPressEvent(self, *args, **kwargs):
event = args[0]
key = event.key()
ctrl = event.modifiers() == QtCore.Qt.ControlModifier
# don't disturb the completer behavior
if self.completer.popup().isVisible() and key in (Qt.Key_Enter, Qt.Key_Return, Qt.Key_Tab, Qt.Key_Backtab):
event.ignore()
return
if self.autocompleteStart is not None and not event.text().isalnum() and \
not (key == Qt.Key_Backspace and self.textCursor().position() > self.autocompleteStart):
self.completer.popup().hide()
self.autocompleteStart = None
if key == Qt.Key_Space and ctrl:
#Pop-up the autocompleteList
rect = self.cursorRect(self.textCursor())
rect.setSize(QtCore.QSize(100, 150))
self.autocompleteStart = self.textCursor().position()
self.completer.complete(rect) # The popup is positioned in the next if block
if self.autocompleteStart:
prefix = self.toPlainText()
cur = self.textCursor()
cur.setPosition(self.autocompleteStart)
self.completer.setCompletionPrefix(prefix)
#Select the first one of the matches
self.completer.popup().setCurrentIndex(self.completer.completionModel().index(0, 0))
if key == Qt.Key_Up and ctrl:
if self.history_index > 0:
self.history_index -= 1
self.setPlainText(BOT_PREFIX + '%s %s' % self.history[self.history_index])
key.ignore()
return
elif key == Qt.Key_Down and ctrl:
if self.history_index < len(self.history) - 1:
self.history_index += 1
self.setPlainText(BOT_PREFIX + '%s %s' % self.history[self.history_index])
key.ignore()
return
elif key == QtCore.Qt.Key_Return and ctrl:
self.newCommand.emit(self.toPlainText())
self.reset_history()
super(CommandBox, self).keyPressEvent(*args, **kwargs)
示例9: CodeCompletionMode
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
class CodeCompletionMode(Mode):
"""
This mode provides code completion to the CodeEdit widget.
The list of suggestion is supplied by a CodeCompletionModel.
Code completion may use more than one completion model. The suggestions
list is then filled model per model by beginning by the highest priority as
long as the number of suggestions is lower than
:attr:`pcef.modes.code_completion.CodeCompletion.minSuggestions`.
For example, a python editor will use a smart completion model with a high
priority and use the DocumentWordsCompletion model as a fallback system
when the smart model fails to provide enough suggestions.
The mode uses a QCompleter to provides display the list of suggestions.
Code completion is triggered using ctrl+space or when there is at least
three characters in the word being typed.
"""
#: Mode identifier
IDENTIFIER = "Code completion"
#: Mode description
DESCRIPTION = "Provides code completion though completion models"
def __init__(self):
super(CodeCompletionMode, self).__init__(
self.IDENTIFIER, self.DESCRIPTION)
self.thread_pool = QThreadPool()
self.thread_pool.setMaxThreadCount(2)
self.__cached_request = None
self.__active_thread_count = 0
self.__updating_models = False
self.__timer = QTimer()
#: Defines the min number of suggestions. This is used to know we should
# avoid using lower priority models.
# If there is at least minSuggestions in the suggestions list, we won't
# use other completion model.
self.minSuggestions = 50
#: Trigger key (automatically associated with the control modifier)
self.triggerKey = Qt.Key_Space
#: Number of chars needed to trigger the code completion
self.nbTriggerChars = 1
#: Tells if the completion should be triggered automatically (when
# len(wordUnderCursor) > nbTriggerChars )
# Default is True. Turning this option off might enhance performances
# and usability
self.autoTrigger = True
self.periodIsTrigger = True
#: Show/Hide current suggestion tooltip
self.displayTooltips = True
self.__caseSensitivity = Qt.CaseSensitive
#: The internal QCompleter
self.__completer = QCompleter()
# self.__completer.activated.connect(self._insertCompletion)
self.__completer.highlighted.connect(self._onHighlighted)
self.__completer.activated.connect(self._insertCompletion)
self.__prev_txt_len = 0
#: List of completion models
self._models = []
self.__tooltips = {}
def __del__(self):
self.__completer.setWidget(None)
self.__completer = None
def addModel(self, model):
"""
Adds a completion model to the completion models list.
:param model: CompletionModel to add
"""
self._models.append(model)
self._models = sorted(self._models, key=lambda mdl: mdl.priority,
reverse=True)
def install(self, editor):
"""
Setup the completer with the CodeEdit.
:param editor: CodeEditorWidget instance
"""
super(CodeCompletionMode, self).install(editor)
self.__completer.setWidget(editor.codeEdit)
self.__completer.setCaseSensitivity(self.__caseSensitivity)
self.__completer.setCompletionMode(QCompleter.PopupCompletion)
def __set_case(self, case):
if case != self.__caseSensitivity:
self.__caseSensitivity = case
self.__completer.setCaseSensitivity(case)
def __get_case(self):
#.........这里部分代码省略.........
示例10: __init__
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
def __init__(self, model, index, parent=None):
super(ObservationDialog, self).__init__(parent)
self.logger = Logger('root.observationDialog')
self.logger.debug('Debug set to: %s' % str(parent.logger.debugging))
self.setupUi(self)
# self.dateTimeEdit.setDateTime(QDateTime.currentDateTime())
# An observation model is passed to the constructor as a parameter
self.model = model
# Build a QCompleter that is based on a species model's species name.
# This way user can start typing the name in a line edit and the
# completion will suggest suitable species names based on the model
# TODO: language for the species name completion needs to be handled
# TODO: both completers have model column indexes hard coded in, thus
# they will break if the model is modified
sppCompleter = QCompleter(self)
sppCompleter.setModel(self.model.data_model)
sppCompleter.setCompletionColumn(4)
sppCompleter.setCompletionMode(QCompleter.InlineCompletion)
sppCompleter.setCaseSensitivity(Qt.CaseInsensitive)
self.sppLineEdit.setCompleter(sppCompleter)
# Build a QCompleter that is based on a species model's abbreviation.
# This way user can start typing the abbreviation in a line edit and the
# completion will suggest suitable species names based on the model
abbrCompleter = QCompleter(self)
abbrCompleter.setModel(self.model.data_model)
abbrCompleter.setCompletionColumn(1)
abbrCompleter.setCompletionMode(QCompleter.InlineCompletion)
self.abbrLineEdit.setCompleter(abbrCompleter)
# The underlying (observation) model is automatically updated through
# a QDataWidgetMapper
self.mapper = QDataWidgetMapper(self)
self.mapper.setSubmitPolicy(QDataWidgetMapper.ManualSubmit)
self.mapper.setModel(model)
# ID is mapped to a disabled dummy label in order to include it in the
# WidgetMapper --> not very elegant
self.mapper.addMapping(self.idLineEdit, model.ID)
self.mapper.addMapping(self.sppLineEdit, model.SPECIES)
self.mapper.addMapping(self.abbrLineEdit, model.ABBR)
self.mapper.addMapping(self.countSpinBox, model.COUNT)
self.mapper.addMapping(self.dateTimeEdit, model.TIME)
self.mapper.addMapping(self.locLineEdit, model.LOCATION)
self.mapper.addMapping(self.notesTextEdit, model.NOTES)
self.mapper.setCurrentModelIndex(index)
self.firstButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.FIRST))
self.prevButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.PREV))
self.nextButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.NEXT))
self.lastButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.LAST))
self.saveButton.clicked.connect(
lambda: self.saveRecord(ObservationDialog.CURRENT))
self.closeButton.clicked.connect(self.reject)
self.sppLineEdit.editingFinished.connect(self.update_fields)
示例11: mainwin
# 需要导入模块: from PySide.QtGui import QCompleter [as 别名]
# 或者: from PySide.QtGui.QCompleter import setCaseSensitivity [as 别名]
class mainwin(QMainWindow):
def __init__(self, parent=None):
super(mainwin, self).__init__(parent)
self.setWindowTitle("Nigandu English to Tamil Dictionary")
self.setGeometry(200, 50, 650, 600)
self.setMinimumHeight(620)
self.setMinimumWidth(650)
self.setMaximumHeight(660)
self.setMaximumWidth(800)
#Setting up status bar
self.myStatusBar = QStatusBar()
self.myStatusBar.showMessage('Ready', 7000)
self.setStatusBar(self.myStatusBar)
#Setting up application icon
appIcon = QIcon(":/icons/njnlogo.png")
self.setWindowIcon(appIcon)
# defining the central widget
self.central = QWidget(self)
#combobox plus search button
self.whole = QVBoxLayout(self.central)
self.gridlayout = QGridLayout()
self.comboBox = QLineEdit(self)
#self.comboBox.setEditable(True)
self.comboBox.setObjectName("comboBox")
self.completer = QCompleter(self.comboBox)
self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setMaxVisibleItems(10)
self.comboBox.setCompleter(self.completer)
#self.comboBox.setCompleter()
self.gridlayout.addWidget(self.comboBox, 1, 1, 1, 2)
self.searchbtn = QPushButton()
self.searchbtn.setObjectName("searchbtn")
self.searchbtn.setText("&Search")
self.gridlayout.addWidget(self.searchbtn, 1, 3)
vbox = QVBoxLayout()
self.tamtext = QTextBrowser()
self.listview = QListWidget(self)
#self.listview.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.listview.setWindowTitle("Suggested words")
self.tamtext.setMinimumHeight(100)
self.tamtext.setMaximumHeight(150)
vbox.addWidget(self.tamtext)
self.suglbl = QLabel(self)
self.suglbl.setText("Suggested Words:")
vbox.addWidget(self.suglbl)
vbox.addWidget(self.listview)
self.whole.addLayout(self.gridlayout)
self.whole.addLayout(vbox)
self.setCentralWidget(self.central)
#setting docks
self.histdockwidg = QDockWidget("History", self)
self.bkmdockwidg = QDockWidget("Book Marks", self)
self.histdockwidg.setObjectName("self.histdockwidg")
self.bkmdockwidg.setObjectName("self.bkmdockwidg")
#self.histdockwidg.setMaximumWidth(histwidth)
self.histdockwidg.setAllowedAreas(Qt.RightDockWidgetArea)
self.bkmdockwidg.setAllowedAreas(Qt.RightDockWidgetArea)
self.histdockwidg.setMaximumWidth(250)
self.bkmdockwidg.setMaximumWidth(250)
self.histdockwidg.setMinimumWidth(200)
self.bkmdockwidg.setMinimumWidth(200)
#self.bkmdockwidg.setMaximumWidth(histwidth)
self.histli = QListWidget()
self.bkmli = QListWidget()
self.histlis = [0]
self.bkmlistfromfile = []
self.histdockwidg.setWidget(self.histli)
self.bkmdockwidg.setWidget(self.bkmli)
self.addDockWidget(Qt.RightDockWidgetArea, self.histdockwidg)
self.addDockWidget(Qt.RightDockWidgetArea, self.bkmdockwidg)
#file menu
fi_addwrd = self.createactions("&Add a word...", self.addwrdf, "Alt+A", ":/icons/add.png",
"Add a word to the dictionary. . .")
fi_options = self.createactions("&Options", self.optionsf, "None", ":/icons/options.png",
"Change the default settings. . .")
fi_help = self.createactions("&Help", self.helpf, QKeySequence.HelpContents, ":/icons/help.png",
"Help contents. . .")
fi_quit = self.createactions("&Quit", self.close, QKeySequence.Close, ":/icons/quit.png",
"Close the application. . .")
fplus = self.createactions("FontPlus", self.fplusf, "None", ":/icons/fplus.png", "Increase the font size")
fminus = self.createactions("FontMinus", self.fminusf, "None", ":/icons/fminus.png", "Decrease the font size")
#list of file actions
fi_menu = (fi_addwrd, fi_options, fi_help, None, fi_quit)
#go menu
self.go_prev = self.createactions("&Previous Word", self.prevf, "Alt+Z", ":/icons/prev.png",
"Previous Word")
self.go_next = self.createactions("&Next Word", self.nextf, "Alt+X", ":/icons/next.png", "Next Word")
self.go_rand = self.createactions("&Random Word", self.randf, "Ctrl+R", ":/icons/rand.png",
"Select a random word")
#.........这里部分代码省略.........