本文整理汇总了Python中PyQt5.QtWidgets.QCompleter.currentCompletion方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.currentCompletion方法的具体用法?Python QCompleter.currentCompletion怎么用?Python QCompleter.currentCompletion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QCompleter
的用法示例。
在下文中一共展示了QCompleter.currentCompletion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Completer
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import currentCompletion [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()
示例2: PestaniaProducto
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import currentCompletion [as 别名]
class PestaniaProducto():
def __init__(self, winPrincipal):
self.winPrincipal = winPrincipal
self.producto = Producto()
self.proveedor = Proveedor()
self.marca = Marca()
self.rubro = Rubro()
self.estado = ""
self.conexionProducto = conexionProducto()
self.completerRubro = QCompleter()
self.completerMarca = QCompleter()
self.completerProveedor = QCompleter()
self.configInit()
def configInit(self):
#Configurando botones
self.winPrincipal.btnAgregar_p.clicked.connect(self.onClickAgregar_p)
self.winPrincipal.btnGuardar_p.clicked.connect(self.onClickGuardar_p)
self.winPrincipal.btnBorrar_p.clicked.connect(self.onClickBorrar_p)
self.winPrincipal.btnModificar_p.clicked.connect(self.onClickModificar_p)
self.winPrincipal.btnRubro_p.clicked.connect(windowRubro)
self.winPrincipal.btnMarca_p.clicked.connect(windowMarca)
#windowMarca.connect(windowMarca, Qt.SIGNAL('destroyed()'), self.onQuitMarca)
self.winPrincipal.txtFilterProductos_p.returnPressed.connect(self.search)
#self.cargarTabla()
self.winPrincipal.tvProductos_p.setMouseTracking(True)
self.winPrincipal.tvProductos_p.setSelectionBehavior(QAbstractItemView.SelectRows)
self.setCompleterMarca()
self.setCompleterRubro()
self.setCompleterProveedor()
self.winPrincipal.txtFilterProductos_p.setFocus(True)
def finish(self):
self.winPrincipal.btnAgregar_p.disconnect()
self.winPrincipal.btnGuardar_p.disconnect()
self.winPrincipal.btnModificar_p.disconnect()
self.winPrincipal.btnBorrar_p.disconnect()
self.winPrincipal.btnRubro_p.disconnect()
self.winPrincipal.btnMarca_p.disconnect()
self.winPrincipal.tvProductos_p.disconnect()
def search(self):
if self.winPrincipal.txtFilterProductos_p.hasFocus() is True:
self.cargarTabla()
def onClickAgregar_p(self):
self.estado = 'AGREGAR'
self.validarBotones(button='AGREGAR')
def onClickGuardar_p(self):
validar = self.validar()
if validar != "":
print(validar)
alert = QDialog()
QMessageBox.information(alert,"ERROR", validar)
else:
self.producto.setDescripcion(str(self.winPrincipal.txtDescripcion_p.toPlainText()))
self.producto.setCantidad(int(self.winPrincipal.sbCantidad_p.value()))
self.producto.setCantidadMinima(int(self.winPrincipal.sbCantidadMin_p.value()))
if self.winPrincipal.cbEstado_p.currentText() == "ACTIVO":
self.producto.setEstado(1)
else:
self.producto.setEstado(0)
if self.winPrincipal.rbFemenino_p.isChecked() is True:
self.producto.setGenero("F")
elif self.winPrincipal.rbMasculino_p.isChecked() is True:
self.producto.setGenero("M")
else:
self.producto.setGenero("I")
self.producto.setNombre(str(self.winPrincipal.txtNombre_p.text()))
self.producto.setPrecioCompra(float(self.winPrincipal.txtPrecioCompra_p.text()))
self.producto.setPrecioVenta(float(self.winPrincipal.txtPrecioVenta_p.text()))
self.rubro.setRubro(str(self.completerRubro.currentCompletion()))
self.producto.setRubro(self.rubro)
self.proveedor.setDescripcion(str(self.completerProveedor.currentCompletion()))
self.producto.setProveedor(self.proveedor)
self.marca.setMarca(str(self.completerMarca.currentCompletion()))
self.producto.setMarca(self.marca)
if self.estado == 'AGREGAR':
self.insertarProducto()
elif self.estado == 'MODIFICAR':
self.modificarProducto()
#.........这里部分代码省略.........