当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QCompleter类代码示例

本文整理汇总了Python中PySide.QtGui.QCompleter的典型用法代码示例。如果您正苦于以下问题:Python QCompleter类的具体用法?Python QCompleter怎么用?Python QCompleter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QCompleter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 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)
开发者ID:joshuatobin,项目名称:err,代码行数:7,代码来源:graphic.py

示例2: __create_filter_ui

    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
开发者ID:Bioeden,项目名称:dbMayaTextureToolkit,代码行数:29,代码来源:mttFilterFileDialog.py

示例3: buildWorkFrame

    def buildWorkFrame(self):
        """Creates the grouped set of widgets that allow users to build
           basic Clause objects.
        """
        groupBox = QGroupBox("Clause Workspace")
        layout = QHBoxLayout(groupBox)

        attributeCompleter = QCompleter(self.attributes)
        attributeCompleter.setCompletionMode(QCompleter.InlineCompletion)
        self.dropAttribute = DropLineEdit(self, self.mframe.agent.datatree, "",
            attributeCompleter)
        self.dropRelation = DropTextLabel("__")
        self.dropValue = FilterValueLineEdit(groupBox,
            self.mframe.agent.datatree, self.dropAttribute)

        # Clear dropValue when dropAttribute changes
        self.dropAttribute.textChanged.connect(self.dropValue.clear)

        # Enter in dropValue works like addButton
        self.dropValue.returnPressed.connect(self.addClause)

        self.addButton = QPushButton("Add", groupBox)
        self.addButton.clicked.connect(self.addClause)
        layout.addWidget(self.dropAttribute)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.dropRelation)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.dropValue)
        layout.addItem(QSpacerItem(5,5))
        layout.addWidget(self.addButton)

        groupBox.setLayout(layout)
        return groupBox
开发者ID:LLNL,项目名称:boxfish,代码行数:33,代码来源:FilterBox.py

示例4: Completer

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()
开发者ID:Kampbell,项目名称:opengeode,代码行数:59,代码来源:TextInteraction.py

示例5: RuleTextEdit

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
开发者ID:SevenLines,项目名称:Python-Turing-Machine,代码行数:58,代码来源:RuleTextEdit.py

示例6: createEditor

 def createEditor(self, parent, option, index):
     """ Should return a LineEdit with all the Category Names as AutoComplete values """
     edit = QLineEdit(parent)
     completer = QCompleter()
     edit.setCompleter(completer) 
     model = QStringListModel()
     completer.setModel(model)
     self.setCompleterData(model)
     return edit
开发者ID:cloew,项目名称:PersonalAccountingSoftware,代码行数:9,代码来源:transaction_category_delegate.py

示例7: configure_search_lineedit

 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
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:10,代码来源:table.py

示例8: config_completer

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)
开发者ID:raulvc,项目名称:seareiros,代码行数:9,代码来源:util.py

示例9: focusInEvent

 def focusInEvent(self, e):
     """On focus, this completer for this LineEdit will update its
        values based on the attribute named in the watchLineEdit.
     """
     super(FilterValueLineEdit, self).focusInEvent(e)
     if self.oldText != self.watchLineEdit.text():
         self.oldText = self.watchLineEdit.text()
         values = self.datatree.getAttributeValues(
             self.watchLineEdit.text())
         self.setCompleter(None)
         new_completer = QCompleter(values)
         new_completer.setCompletionMode(QCompleter.InlineCompletion)
         self.setCompleter(new_completer)
开发者ID:LLNL,项目名称:boxfish,代码行数:13,代码来源:FilterBox.py

示例10: TagEdit

class TagEdit(object):
    """Abstraction for tag edit"""

    def __init__(self, parent, widget, on_change):
        """Init and connect signals"""
        self.parent = parent
        self.app = QApplication.instance()
        self.widget = widget
        self.tags_list = map(lambda tag:
            Tag.from_tuple(tag).name,
            self.app.provider.list_tags(),
        )
        self.completer = QCompleter()
        self.completer_model = QStringListModel()
        self.completer.setModel(self.completer_model)
        self.completer.activated.connect(self.update_completion)
        self.update_completion()
        self.widget.setCompleter(self.completer)
        self.widget.textChanged.connect(Slot()(on_change))
        self.widget.textEdited.connect(self.update_completion)

    @property
    def tags(self):
        """Get tags"""
        # Split on comma and Arabic comma
        # 0x060c is the Arabic comma
        return map(lambda tag: tag.strip(),
            re.split(u',|\u060c', self.widget.text()))

    @tags.setter
    def tags(self, val):
        """Set tags"""
        self.widget.setText(', '.join(val))

    @Slot()
    def update_completion(self):
        """Update completion model with exist tags"""
        orig_text = self.widget.text()
        text = ', '.join(orig_text.replace(', ', ',').split(',')[:-1])
        tags = []
        for tag in self.tags_list:
            if ',' in orig_text:
                if orig_text[-1] not in (',', ' '):
                    tags.append('%s,%s' % (text, tag))
                tags.append('%s, %s' % (text, tag))
            else:
                tags.append(tag)
        if tags != self.completer_model.stringList():
            self.completer_model.setStringList(tags)
开发者ID:KamranMackey,项目名称:everpad,代码行数:49,代码来源:widgets.py

示例11: updateCompletion

 def updateCompletion(self, commands):
     if self.completer:
         self.completer.activated.disconnect(self.onAutoComplete)
     self.completer = QCompleter([(self.prefix + name).replace('_', ' ', 1) for name in commands], self)
     self.completer.setCaseSensitivity(Qt.CaseInsensitive)
     self.completer.setWidget(self)
     self.completer.activated.connect(self.onAutoComplete)
开发者ID:carriercomm,项目名称:lctv,代码行数:7,代码来源:graphic.py

示例12: TagEdit

class TagEdit(object):
    """Abstraction for tag edit"""

    def __init__(self, parent, app, widget, on_change):
        """Init and connect signals"""
        self.parent = parent
        self.app = app
        self.widget = widget
        self.tags_list = map(lambda tag: Tag.from_tuple(tag).name, self.app.provider.list_tags())
        self.completer = QCompleter()
        self.completer_model = QStringListModel()
        self.completer.setModel(self.completer_model)
        self.completer.activated.connect(self.update_completion)
        self.update_completion()
        self.widget.setCompleter(self.completer)
        self.widget.textChanged.connect(Slot()(on_change))
        self.widget.textEdited.connect(self.update_completion)

    @property
    def tags(self):
        """Get tags"""
        return map(lambda tag: tag.strip(), self.widget.text().split(","))

    @tags.setter
    def tags(self, val):
        """Set tags"""
        self.widget.setText(", ".join(val))

    @Slot()
    def update_completion(self):
        """Update completion model with exist tags"""
        orig_text = self.widget.text()
        text = ", ".join(orig_text.replace(", ", ",").split(",")[:-1])
        tags = []
        for tag in self.tags_list:
            if "," in orig_text:
                if orig_text[-1] not in (",", " "):
                    tags.append("%s,%s" % (text, tag))
                tags.append("%s, %s" % (text, tag))
            else:
                tags.append(tag)
        if tags != self.completer_model.stringList():
            self.completer_model.setStringList(tags)
开发者ID:fabianofranz,项目名称:everpad,代码行数:43,代码来源:editor.py

示例13: __init__

    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)
开发者ID:SevenLines,项目名称:Python-Turing-Machine,代码行数:12,代码来源:RuleTextEdit.py

示例14: __init__

    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
开发者ID:linuxtechie,项目名称:err,代码行数:12,代码来源:graphic.py

示例15: __init__

 def __init__(self, parent, app, widget, on_change):
     """Init and connect signals"""
     self.parent = parent
     self.app = app
     self.widget = widget
     self.tags_list = map(lambda tag: Tag.from_tuple(tag).name, self.app.provider.list_tags())
     self.completer = QCompleter()
     self.completer_model = QStringListModel()
     self.completer.setModel(self.completer_model)
     self.completer.activated.connect(self.update_completion)
     self.update_completion()
     self.widget.setCompleter(self.completer)
     self.widget.textChanged.connect(Slot()(on_change))
     self.widget.textEdited.connect(self.update_completion)
开发者ID:fabianofranz,项目名称:everpad,代码行数:14,代码来源:editor.py


注:本文中的PySide.QtGui.QCompleter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。