本文整理汇总了Python中PyQt4.QtGui.QItemDelegate.createEditor方法的典型用法代码示例。如果您正苦于以下问题:Python QItemDelegate.createEditor方法的具体用法?Python QItemDelegate.createEditor怎么用?Python QItemDelegate.createEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QItemDelegate
的用法示例。
在下文中一共展示了QItemDelegate.createEditor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
delegate = self.delegates.get(index.column())
if delegate is not None:
return delegate.createEditor(parent, option, index)
else:
return QItemDelegate.createEditor(self, parent, option,
index)
示例2: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
if index.parent().isValid():
# item has a parent -> no SimulationModule
# TODO implement dropdown menu if property is a dict
return QItemDelegate.createEditor(self, parent, option, index)
else:
# no parent -> top of hierarchy
return self.comboDel.createEditor(parent, option, index)
示例3: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
# special combobox for field type
if index.column() == self.column:
cbo = QComboBox(parent)
for item in self.itemsDict:
cbo.addItem(item, self.itemsDict[item])
return cbo
return QItemDelegate.createEditor(self, parent, option, index)
示例4: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
# special combobox for field type
if index.column() == 1:
cbo = QComboBox(parent)
cbo.setEditable(True)
cbo.setAutoCompletion(True)
cbo.setFrame(False)
for item in self.fieldTypes:
cbo.addItem(item)
return cbo
return QItemDelegate.createEditor(self, parent, option, index)
示例5: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
if index.column() in (MOD1, MOD2, MOD3):
combobox = QComboBox(parent)
combobox.addItems(self.modifiers)
return combobox
elif index.column() == KEY:
combobox = QComboBox(parent)
combobox.addItems(self.keys)
return combobox
else:
return QItemDelegate.createEditor(self, parent, option,
index)
示例6: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self,parent,option,index):
"""create widgets to edit values"""
if index.column() == 1:
cbox = QComboBox(parent)
cbox.setMaxVisibleItems(10)
self.updateEditorGeometry(cbox, option,index )
for pos,value in enumerate([0,20,30,40,50,60,70,80,90,100]):
icon = QPixmap(20,10)
icon.fill(self._getColorForProgress(value))
cbox.insertItem(pos, QIcon(icon),"",value)
cbox.showPopup()
return cbox
else:
return QItemDelegate.createEditor(self,parent,option,index)
示例7: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
model = index.model()
if model.isColumn("name", index):
textedit = QLineEdit(parent)
return textedit
elif model.isColumn("rating", index):
spinbox = QSpinBox(parent)
spinbox.setRange(0, 200)
spinbox.setSingleStep(1)
spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
return spinbox
elif model.isColumn("adjust", index):
spinbox = QSpinBox(parent)
spinbox.setRange(-10, 10)
spinbox.setSingleStep(1)
spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
return spinbox
else:
return QItemDelegate.createEditor(self, parent, option, index)
示例8: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent, option, index):
if len(self._view.selectedIndexes()) > 1:
self._selected_indexes = self._view.selectedIndexes()
columns = index.model().get_git_model().get_columns()
field_name = columns[index.column()]
if field_name in TEXT_FIELDS:
editor = QTextEdit(parent)
elif field_name in ACTOR_FIELDS:
editor = QLineEdit(parent)
elif field_name in TIME_FIELDS:
editor = QDateTimeEdit(parent)
editor.setDisplayFormat("yyyy-MM-dd hh:mm:ss")
else:
return QItemDelegate.createEditor(self, parent, option,
index)
self.connect(editor, SIGNAL("returnPressed()"),
self.commitAndCloseEditor)
return editor
示例9: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex):
return QItemDelegate.createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex)
示例10: createEditor
# 需要导入模块: from PyQt4.QtGui import QItemDelegate [as 别名]
# 或者: from PyQt4.QtGui.QItemDelegate import createEditor [as 别名]
def createEditor(self, parent_view, option, index):
""" PyQt API Method -- See the PyQt documentation for a description """
default_editor = QItemDelegate.createEditor(self, parent_view, option, index)
if not index.isValid():
return default_editor
item = index.internalPointer()
node = item.node
# editing of left hand columns is handled by dialogs etc, don't allow direct editing
if index.column() == 0:
pass
elif index.column() == 1:
# Combobox for multiple choices
editor = default_editor
# CK delete the following comment if the xml schema is complete and does'nt contain any 'choices'
# if node.get('choices') is not None:
# editor = QComboBox(parent_view)
# choices = [s.strip() for s in node.get('choices').split('|')]
# for item in choices:
# editor.addItem(item)
# # Select the current choice
# choice = node.text.strip() if node.text else ''
# if choice in choices:
# editor.setCurrentIndex(choices.index(choice))
# Create and prepare an editor for the node
# Select database connection
if node.get("type") == "db_connection_hook":
editor = QComboBox(parent_view)
# Get connection names from database_server_connections.xml
choices = get_db_connection_names()
# Populate the editor with the choices
for i in choices:
editor.addItem(i)
# Select files and folders
elif node.get("type") in ("file_path", "dir_path"):
editor_file = QFileDialog()
filter_str = QString("*.*")
editor_file.setFilter(filter_str)
editor_file.setAcceptMode(QFileDialog.AcceptOpen)
current_value = index.model().data(index, Qt.DisplayRole).toString()
if node.get("type") == "file_path":
method = editor_file.getOpenFileName
title = "Please select a file..."
else:
method = editor_file.getExistingDirectory
title = "Please select a directory..."
fd = method(self.parent_view, title, current_value)
# Check for cancel
if len(fd) == 0:
new_value = current_value
else:
new_value = QString(fd)
editor = QItemDelegate.createEditor(self, self.parent_view, option, index)
if type(editor) == QLineEdit:
editor.setText(new_value)
# Edit passwords
elif node.get("type") == "password":
editor.setText(str(node.text or ""))
editor.setStyleSheet("QLineEdit { background-color: red }")
editor.setEchoMode(QLineEdit.PasswordEchoOnEdit)
# Use default editor
else:
if type(editor) == QLineEdit:
txt = index.model().data(index, Qt.DisplayRole).toString()
editor.setText(txt)
return editor