本文整理汇总了Python中PyQt5.QtWidgets.QCompleter.setCurrentRow方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.setCurrentRow方法的具体用法?Python QCompleter.setCurrentRow怎么用?Python QCompleter.setCurrentRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QCompleter
的用法示例。
在下文中一共展示了QCompleter.setCurrentRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Completer
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import setCurrentRow [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 setCurrentRow [as 别名]
#.........这里部分代码省略.........
self.winPrincipal.btnBorrar_p.setEnabled(True)
self.winPrincipal.tvProductos_p.setEnabled(False)
self.winPrincipal.wDatosProducto.setEnabled(True)
elif button=='BORRAR':
self.winPrincipal.btnModificar_p.setEnabled(False)
self.winPrincipal.btnAgregar_p.setEnabled(True)
self.winPrincipal.btnGuardar_p.setEnabled(False)
self.winPrincipal.btnBorrar_p.setText('BORRAR')
self.winPrincipal.btnBorrar_p.setEnabled(False)
self.winPrincipal.tvProductos_p.setEnabled(True)
self.winPrincipal.wDatosProducto.setEnabled(False)
self.limpiarCampos()
def insertarProducto(self):
self.conexionProducto.insertarProducto(producto=self.producto)
self.cargarTabla()
def modificarProducto(self):
self.conexionProducto.modificarProducto(self.producto)
self.cargarTabla()
def limpiarCampos(self):
self.winPrincipal.txtNombre_p.setText('')
self.winPrincipal.txtPrecioCompra_p.setText('')
self.winPrincipal.txtPrecioVenta_p.setText('')
self.winPrincipal.sbCantidad_p.setValue(0)
self.winPrincipal.sbCantidadMin_p.setValue(0)
self.winPrincipal.txtProveedor_p.setText('')
self.winPrincipal.txtDescripcion_p.setText('')
self.winPrincipal.txtRubro_p.setText('')
self.winPrincipal.txtMarca_p.setText('')
self.completerProveedor.setCurrentRow(0)
self.completerRubro.setCurrentRow(0)
self.completerMarca.setCurrentRow(0)
self.winPrincipal.txtFilterProductos_p.setText('')
self.winPrincipal.tvProductos_p.setModel(None)
self.winPrincipal.txtFilterProductos_p.setFocus(True)
def setCampos(self):
self.winPrincipal.txtNombre_p.setText(self.producto.getNombre())
self.winPrincipal.txtDescripcion_p.setText(str(self.producto.getDescripcion()))
self.winPrincipal.txtPrecioCompra_p.setText(str(self.producto.getPrecioCompra()))
self.winPrincipal.txtPrecioVenta_p.setText(str(self.producto.getPrecioVenta()))
self.winPrincipal.txtProveedor_p.setText(str(self.producto.getProveedor().getDescripcion()))
self.winPrincipal.sbCantidad_p.setValue(int(self.producto.getCantidad()))
self.winPrincipal.sbCantidadMin_p.setValue(int(self.producto.getCantidadMinima()))
self.winPrincipal.txtRubro_p.setText(str(self.producto.getRubro().getRubro()))
self.winPrincipal.txtMarca_p.setText(str(self.producto.getMarca().getMarca()))
if self.producto.getEstado() == 1:
self.winPrincipal.cbEstado_p.setCurrentIndex(0)
else:
self.winPrincipal.cbEstado_p.setCurrentIndex(1)
if self.producto.getGenero() == 'F':
self.winPrincipal.rbFemenino_p.setChecked(True)
elif self.producto.getGenero() == 'M':
self.winPrincipal.rbMasculino_p.setChecked(True)
else:
self.winPrincipal.rbIndiferente_p.setChecked(True)