本文整理汇总了Python中AnyQt.QtWidgets.QLineEdit.setCompleter方法的典型用法代码示例。如果您正苦于以下问题:Python QLineEdit.setCompleter方法的具体用法?Python QLineEdit.setCompleter怎么用?Python QLineEdit.setCompleter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setCompleter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWSelectAttributes
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
class OWSelectAttributes(widget.OWWidget):
name = "Select Columns"
description = "Select columns from the data table and assign them to " \
"data features, classes or meta variables."
icon = "icons/SelectColumns.svg"
priority = 100
inputs = [("Data", Table, "set_data")]
outputs = [("Data", Table), ("Features", widget.AttributeList)]
want_main_area = False
want_control_area = True
settingsHandler = SelectAttributesDomainContextHandler()
domain_role_hints = ContextSetting({})
auto_commit = Setting(False)
def __init__(self):
super().__init__()
self.controlArea = QWidget(self.controlArea)
self.layout().addWidget(self.controlArea)
layout = QGridLayout()
self.controlArea.setLayout(layout)
layout.setContentsMargins(4, 4, 4, 4)
box = gui.vBox(self.controlArea, "Available Variables",
addToLayout=False)
self.filter_edit = QLineEdit()
self.filter_edit.setToolTip("Filter the list of available variables.")
box.layout().addWidget(self.filter_edit)
if hasattr(self.filter_edit, "setPlaceholderText"):
self.filter_edit.setPlaceholderText("Filter")
self.completer = QCompleter()
self.completer.setCompletionMode(QCompleter.InlineCompletion)
self.completer_model = QStringListModel()
self.completer.setModel(self.completer_model)
self.completer.setModelSorting(
QCompleter.CaseSensitivelySortedModel)
self.filter_edit.setCompleter(self.completer)
self.completer_navigator = CompleterNavigator(self)
self.filter_edit.installEventFilter(self.completer_navigator)
def dropcompleted(action):
if action == Qt.MoveAction:
self.commit()
self.available_attrs = VariableListModel(enable_dnd=True)
self.available_attrs_proxy = VariableFilterProxyModel()
self.available_attrs_proxy.setSourceModel(self.available_attrs)
self.available_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.available_attrs_view.setModel(self.available_attrs_proxy)
aa = self.available_attrs
aa.dataChanged.connect(self.update_completer_model)
aa.rowsInserted.connect(self.update_completer_model)
aa.rowsRemoved.connect(self.update_completer_model)
self.available_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.available_attrs_view))
self.available_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.filter_edit.textChanged.connect(self.update_completer_prefix)
self.filter_edit.textChanged.connect(
self.available_attrs_proxy.set_filter_string)
box.layout().addWidget(self.available_attrs_view)
layout.addWidget(box, 0, 0, 3, 1)
box = gui.vBox(self.controlArea, "Features", addToLayout=False)
self.used_attrs = VariableListModel(enable_dnd=True)
self.used_attrs_view = VariablesListItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.used_attrs_view.setModel(self.used_attrs)
self.used_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.used_attrs_view))
self.used_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
box.layout().addWidget(self.used_attrs_view)
layout.addWidget(box, 0, 2, 1, 1)
box = gui.vBox(self.controlArea, "Target Variable", addToLayout=False)
self.class_attrs = ClassVarListItemModel(enable_dnd=True)
self.class_attrs_view = ClassVariableItemView(
acceptedType=(Orange.data.DiscreteVariable,
Orange.data.ContinuousVariable))
self.class_attrs_view.setModel(self.class_attrs)
self.class_attrs_view.selectionModel().selectionChanged.connect(
partial(self.update_interface_state, self.class_attrs_view))
self.class_attrs_view.dragDropActionDidComplete.connect(dropcompleted)
self.class_attrs_view.setMaximumHeight(24)
box.layout().addWidget(self.class_attrs_view)
layout.addWidget(box, 1, 2, 1, 1)
box = gui.vBox(self.controlArea, "Meta Attributes", addToLayout=False)
self.meta_attrs = VariableListModel(enable_dnd=True)
self.meta_attrs_view = VariablesListItemView(
acceptedType=Orange.data.Variable)
self.meta_attrs_view.setModel(self.meta_attrs)
self.meta_attrs_view.selectionModel().selectionChanged.connect(
#.........这里部分代码省略.........
示例2: OWDatabasesUpdate
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
class OWDatabasesUpdate(OWWidget):
name = "Databases Update"
description = "Update local systems biology databases."
icon = "../widgets/icons/Databases.svg"
priority = 10
inputs = []
outputs = []
want_main_area = False
def __init__(self, parent=None, signalManager=None,
name="Databases update"):
OWWidget.__init__(self, parent, signalManager, name,
wantMainArea=False)
self.searchString = ""
fbox = gui.widgetBox(self.controlArea, "Filter")
self.completer = TokenListCompleter(
self, caseSensitivity=Qt.CaseInsensitive)
self.lineEditFilter = QLineEdit(textChanged=self.SearchUpdate)
self.lineEditFilter.setCompleter(self.completer)
fbox.layout().addWidget(self.lineEditFilter)
box = gui.widgetBox(self.controlArea, "Files")
self.filesView = QTreeWidget(self)
self.filesView.setHeaderLabels(
["", "Data Source", "Update", "Last Updated", "Size"])
self.filesView.setRootIsDecorated(False)
self.filesView.setUniformRowHeights(True)
self.filesView.setSelectionMode(QAbstractItemView.NoSelection)
self.filesView.setSortingEnabled(True)
self.filesView.sortItems(1, Qt.AscendingOrder)
self.filesView.setItemDelegateForColumn(
0, UpdateOptionsItemDelegate(self.filesView))
self.filesView.model().layoutChanged.connect(self.SearchUpdate)
box.layout().addWidget(self.filesView)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
self.updateButton = gui.button(
box, self, "Update all",
callback=self.UpdateAll,
tooltip="Update all updatable files",
)
self.downloadButton = gui.button(
box, self, "Download all",
callback=self.DownloadFiltered,
tooltip="Download all filtered files shown"
)
self.cancelButton = gui.button(
box, self, "Cancel", callback=self.Cancel,
tooltip="Cancel scheduled downloads/updates."
)
self.retryButton = gui.button(
box, self, "Reconnect", callback=self.RetrieveFilesList
)
self.retryButton.hide()
gui.rubber(box)
self.warning(0)
box = gui.widgetBox(self.controlArea, orientation="horizontal")
gui.rubber(box)
self.infoLabel = QLabel()
self.infoLabel.setAlignment(Qt.AlignCenter)
self.controlArea.layout().addWidget(self.infoLabel)
self.infoLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.updateItems = []
self.resize(800, 600)
self.progress = ProgressState(self, maximum=3)
self.progress.valueChanged.connect(self._updateProgress)
self.progress.rangeChanged.connect(self._updateProgress)
self.executor = ThreadExecutor(
threadPool=QThreadPool(maxThreadCount=2)
)
task = Task(self, function=self.RetrieveFilesList)
task.exceptionReady.connect(self.HandleError)
task.start()
self._tasks = []
self._haveProgress = False
def RetrieveFilesList(self):
self.retryButton.hide()
#.........这里部分代码省略.........
示例3: SelectionSetsWidget
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
class SelectionSetsWidget(QFrame):
"""
Widget for managing multiple stored item selections
"""
selectionModified = Signal(bool)
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setContentsMargins(0, 0, 0, 0)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(1)
self._setNameLineEdit = QLineEdit(self)
layout.addWidget(self._setNameLineEdit)
self._setListView = QListView(self)
self._listModel = QStandardItemModel(self)
self._proxyModel = QSortFilterProxyModel(self)
self._proxyModel.setSourceModel(self._listModel)
self._setListView.setModel(self._proxyModel)
self._setListView.setItemDelegate(ListItemDelegate(self))
self._setNameLineEdit.textChanged.connect(
self._proxyModel.setFilterFixedString)
self._completer = QCompleter(self._listModel, self)
self._setNameLineEdit.setCompleter(self._completer)
self._listModel.itemChanged.connect(self._onSetNameChange)
layout.addWidget(self._setListView)
buttonLayout = QHBoxLayout()
self._addAction = QAction(
"+", self, toolTip="Add a new sort key")
self._updateAction = QAction(
"Update", self, toolTip="Update/save current selection")
self._removeAction = QAction(
"\u2212", self, toolTip="Remove selected sort key.")
self._addToolButton = QToolButton(self)
self._updateToolButton = QToolButton(self)
self._removeToolButton = QToolButton(self)
self._updateToolButton.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
self._addToolButton.setDefaultAction(self._addAction)
self._updateToolButton.setDefaultAction(self._updateAction)
self._removeToolButton.setDefaultAction(self._removeAction)
buttonLayout.addWidget(self._addToolButton)
buttonLayout.addWidget(self._updateToolButton)
buttonLayout.addWidget(self._removeToolButton)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self._addAction.triggered.connect(self.addCurrentSelection)
self._updateAction.triggered.connect(self.updateSelectedSelection)
self._removeAction.triggered.connect(self.removeSelectedSelection)
self._setListView.selectionModel().selectionChanged.connect(
self._onListViewSelectionChanged)
self.selectionModel = None
self._selections = []
def sizeHint(self):
size = QFrame.sizeHint(self)
return QSize(size.width(), 150)
def _onSelectionChanged(self, selected, deselected):
self.setSelectionModified(True)
def _onListViewSelectionChanged(self, selected, deselected):
try:
index = self._setListView.selectedIndexes()[0]
except IndexError:
return
self.commitSelection(self._proxyModel.mapToSource(index).row())
def _onSetNameChange(self, item):
self.selections[item.row()].name = str(item.text())
def _setButtonStates(self, val):
self._updateToolButton.setEnabled(val)
def setSelectionModel(self, selectionModel):
if self.selectionModel:
self.selectionModel.selectionChanged.disconnect(
self._onSelectionChanged)
self.selectionModel = selectionModel
self.selectionModel.selectionChanged.connect(self._onSelectionChanged)
def addCurrentSelection(self):
item = self.addSelection(
SelectionByKey(self.selectionModel.selection(),
name="New selection",
key=(1, 2, 3, 10)))
index = self._proxyModel.mapFromSource(item.index())
#.........这里部分代码省略.........
示例4: OWGEODatasets
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
class OWGEODatasets(OWWidget):
name = "GEO Data Sets"
description = DESCRIPTION
icon = "../widgets/icons/GEODataSets.svg"
priority = PRIORITY
inputs = []
outputs = [("Expression Data", Orange.data.Table)]
settingsList = ["outputRows", "mergeSpots", "gdsSelectionStates",
"splitterSettings", "currentGds", "autoCommit",
"datasetNames"]
outputRows = Setting(True)
mergeSpots = Setting(True)
gdsSelectionStates = Setting({})
currentGds = Setting(None)
datasetNames = Setting({})
splitterSettings = Setting(
(b'\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xea\x00\x00\x00\xd7\x01\x00\x00\x00\x07\x01\x00\x00\x00\x02',
b'\x00\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\xb5\x00\x00\x02\x10\x01\x00\x00\x00\x07\x01\x00\x00\x00\x01')
)
autoCommit = Setting(False)
def __init__(self, parent=None, signalManager=None, name=" GEO Data Sets"):
OWWidget.__init__(self, parent, signalManager, name)
self.selectionChanged = False
self.filterString = ""
self.datasetName = ""
## GUI
box = gui.widgetBox(self.controlArea, "Info", addSpace=True)
self.infoBox = gui.widgetLabel(box, "Initializing\n\n")
box = gui.widgetBox(self.controlArea, "Output", addSpace=True)
gui.radioButtonsInBox(box, self, "outputRows",
["Genes in rows", "Samples in rows"], "Rows",
callback=self.commitIf)
gui.checkBox(box, self, "mergeSpots", "Merge spots of same gene",
callback=self.commitIf)
gui.separator(box)
self.nameEdit = gui.lineEdit(
box, self, "datasetName", "Data set name",
tooltip="Override the default output data set name",
callback=self.onNameEdited
)
self.nameEdit.setPlaceholderText("")
if sys.version_info < (3, ):
box = gui.widgetBox(self.controlArea, "Commit", addSpace=True)
self.commitButton = gui.button(
box, self, "Commit", callback=self.commit)
cb = gui.checkBox(box, self, "autoCommit", "Commit on any change")
gui.setStopper(self, self.commitButton, cb, "selectionChanged",
self.commit)
else:
gui.auto_commit(self.controlArea, self, "autoCommit", "Commit",
box="Commit")
self.commitIf = self.commit
gui.rubber(self.controlArea)
gui.widgetLabel(self.mainArea, "Filter")
self.filterLineEdit = QLineEdit(
textChanged=self.filter
)
self.completer = TokenListCompleter(
self, caseSensitivity=Qt.CaseInsensitive
)
self.filterLineEdit.setCompleter(self.completer)
self.mainArea.layout().addWidget(self.filterLineEdit)
splitter = QSplitter(Qt.Vertical, self.mainArea)
self.mainArea.layout().addWidget(splitter)
self.treeWidget = QTreeView(splitter)
self.treeWidget.setSelectionMode(QTreeView.SingleSelection)
self.treeWidget.setRootIsDecorated(False)
self.treeWidget.setSortingEnabled(True)
self.treeWidget.setAlternatingRowColors(True)
self.treeWidget.setUniformRowHeights(True)
self.treeWidget.setEditTriggers(QTreeView.NoEditTriggers)
linkdelegate = LinkStyledItemDelegate(self.treeWidget)
self.treeWidget.setItemDelegateForColumn(1, linkdelegate)
self.treeWidget.setItemDelegateForColumn(8, linkdelegate)
self.treeWidget.setItemDelegateForColumn(
0, gui.IndicatorItemDelegate(self.treeWidget,
role=Qt.DisplayRole))
proxyModel = MySortFilterProxyModel(self.treeWidget)
self.treeWidget.setModel(proxyModel)
self.treeWidget.selectionModel().selectionChanged.connect(
self.updateSelection
)
#.........这里部分代码省略.........
示例5: OWSetEnrichment
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
#.........这里部分代码省略.........
pvalfilterbox, self, "maxPValue", 0.0, 1.0, 0.0001,
tooltip="Maximum p-value",
callback=self.filterAnnotationsChartView,
callbackOnReturn=True,
)
sp.setEnabled(self.useMaxFDRFilter)
cb.toggled[bool].connect(sp.setEnabled)
pvalfilterbox.layout().setAlignment(cb, Qt.AlignRight)
pvalfilterbox.layout().setAlignment(sp, Qt.AlignLeft)
fdrfilterbox = gui.widgetBox(hWidget, orientation="horizontal")
cb = gui.checkBox(
fdrfilterbox, self, "useMaxFDRFilter", "FDR",
callback=self.filterAnnotationsChartView)
sp = gui.doubleSpin(
fdrfilterbox, self, "maxFDR", 0.0, 1.0, 0.0001,
tooltip="Maximum False discovery rate",
callback=self.filterAnnotationsChartView,
callbackOnReturn=True,
)
sp.setEnabled(self.useMaxFDRFilter)
cb.toggled[bool].connect(sp.setEnabled)
fdrfilterbox.layout().setAlignment(cb, Qt.AlignRight)
fdrfilterbox.layout().setAlignment(sp, Qt.AlignLeft)
self.filterLineEdit = QLineEdit(
self, placeholderText="Filter ...")
self.filterCompleter = QCompleter(self.filterLineEdit)
self.filterCompleter.setCaseSensitivity(Qt.CaseInsensitive)
self.filterLineEdit.setCompleter(self.filterCompleter)
hLayout.addWidget(self.filterLineEdit)
self.mainArea.layout().addWidget(hWidget)
self.filterLineEdit.textChanged.connect(
self.filterAnnotationsChartView)
self.annotationsChartView = QTreeView(
alternatingRowColors=True,
sortingEnabled=True,
selectionMode=QTreeView.ExtendedSelection,
rootIsDecorated=False,
editTriggers=QTreeView.NoEditTriggers,
)
self.annotationsChartView.viewport().setMouseTracking(True)
self.mainArea.layout().addWidget(self.annotationsChartView)
contextEventFilter = gui.VisibleHeaderSectionContextEventFilter(
self.annotationsChartView)
self.annotationsChartView.header().installEventFilter(contextEventFilter)
self.groupsWidget.itemClicked.connect(self.subsetSelectionChanged)
gui.auto_commit(self.controlArea, self, "autocommit", "Commit")
self.setBlocking(True)
task = EnsureDownloaded(
[(taxonomy.Taxonomy.DOMAIN, taxonomy.Taxonomy.FILENAME),
(geneset.sfdomain, "index.pck")]
)
task.finished.connect(self.__initialize_finish)
示例6: variables_filter
# 需要导入模块: from AnyQt.QtWidgets import QLineEdit [as 别名]
# 或者: from AnyQt.QtWidgets.QLineEdit import setCompleter [as 别名]
def variables_filter(model, parent=None, accepted_type=Orange.data.Variable,
view_type=VariablesListItemView):
"""
GUI components: ListView with a lineedit which works as a filter. One can write
a variable name in a edit box and possible matches are then shown in a listview.
"""
def update_completer_model():
""" This gets called when the model for available attributes changes
through either drag/drop or the left/right button actions.
"""
nonlocal original_completer_items
items = ["%s=%s" % item for v in model for item in v.attributes.items()]
new = sorted(set(items))
if new != original_completer_items:
original_completer_items = new
completer_model.setStringList(original_completer_items)
def update_completer_prefix():
""" Prefixes all items in the completer model with the current
already done completion to enable the completion of multiple keywords.
"""
nonlocal original_completer_items
prefix = str(completer.completionPrefix())
if not prefix.endswith(" ") and " " in prefix:
prefix, _ = prefix.rsplit(" ", 1)
items = [prefix + " " + item
for item in original_completer_items]
else:
items = original_completer_items
old = list(map(str, completer_model.stringList()))
if set(old) != set(items):
completer_model.setStringList(items)
original_completer_items = []
filter_edit = QLineEdit()
filter_edit.setToolTip("Filter the list of available variables.")
filter_edit.setPlaceholderText("Filter")
completer_model = QStringListModel()
completer = QCompleter(completer_model, filter_edit)
completer.setCompletionMode(QCompleter.InlineCompletion)
completer.setModelSorting(QCompleter.CaseSensitivelySortedModel)
filter_edit.setCompleter(completer)
completer_navigator = CompleterNavigator(parent)
filter_edit.installEventFilter(completer_navigator)
proxy = VariableFilterProxyModel()
proxy.setSourceModel(model)
view = view_type(acceptedType=accepted_type)
view.setModel(proxy)
model.dataChanged.connect(update_completer_model)
model.rowsInserted.connect(update_completer_model)
model.rowsRemoved.connect(update_completer_model)
filter_edit.textChanged.connect(update_completer_prefix)
filter_edit.textChanged.connect(proxy.set_filter_string)
return filter_edit, view