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


Python QItemDelegate.createEditor方法代码示例

本文整理汇总了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)
开发者ID:maximerobin,项目名称:Ufwi,代码行数:9,代码来源:genericdelegates.py

示例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)
开发者ID:cklb,项目名称:pymoskito,代码行数:10,代码来源:simulation_interface.py

示例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)
开发者ID:alexdsz,项目名称:DsgTools,代码行数:10,代码来源:manageComplex.py

示例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)
开发者ID:Geoneer,项目名称:QGIS,代码行数:13,代码来源:dlg_create_table.py

示例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)
开发者ID:koll00,项目名称:Gui_SM,代码行数:14,代码来源:shortcuts.py

示例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)
开发者ID:toyg,项目名称:plasmaapplets,代码行数:16,代码来源:main.py

示例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)
开发者ID:Whatang,项目名称:QBetty,代码行数:21,代码来源:RaceDelegate.py

示例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
开发者ID:mike-perdide,项目名称:gitbuster,代码行数:22,代码来源:q_git_delegate.py

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

示例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
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:75,代码来源:xml_item_delegate.py


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