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


Python QStandardItem.setFlags方法代码示例

本文整理汇总了Python中AnyQt.QtGui.QStandardItem.setFlags方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItem.setFlags方法的具体用法?Python QStandardItem.setFlags怎么用?Python QStandardItem.setFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AnyQt.QtGui.QStandardItem的用法示例。


在下文中一共展示了QStandardItem.setFlags方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _cat_desc_to_std_item

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def _cat_desc_to_std_item(self, desc):
        """
        Create a QStandardItem for the category description.
        """
        item = QStandardItem()
        item.setText(desc.name)

        if desc.icon:
            icon = desc.icon
        else:
            icon = "icons/default-category.svg"

        icon = icon_loader.from_description(desc).get(icon)
        item.setIcon(icon)

        if desc.background:
            background = desc.background
        else:
            background = DEFAULT_COLOR

        background = NAMED_COLORS.get(background, background)

        brush = QBrush(QColor(background))
        item.setData(brush, self.BACKGROUND_ROLE)

        tooltip = desc.description if desc.description else desc.name

        item.setToolTip(tooltip)
        item.setFlags(Qt.ItemIsEnabled)
        item.setData(desc, self.CATEGORY_DESC_ROLE)
        return item
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:33,代码来源:qt.py

示例2: _initialize

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def _initialize(self):
        for pp_def in PREPROCESSORS:
            description = pp_def.description
            if description.icon:
                icon = QIcon(description.icon)
            else:
                icon = QIcon()
            item = QStandardItem(icon, description.title)
            item.setToolTip(description.summary or "")
            item.setData(pp_def, DescriptionRole)
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                          Qt.ItemIsDragEnabled)
            self.preprocessors.appendRow([item])

        try:
            model = self.load(self.storedsettings)
        except Exception:
            model = self.load({})

        self.set_model(model)

        if not model.rowCount():
            # enforce default width constraint if no preprocessors
            # are instantiated (if the model is not empty the constraints
            # will be triggered by LayoutRequest event on the `flow_view`)
            self.__update_size_constraint()

        self.apply()
开发者ID:benzei,项目名称:orange3,代码行数:30,代码来源:owpreprocess.py

示例3: addSelection

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def addSelection(self, selection, name=""):
     self._selections.append(selection)
     item = QStandardItem(selection.name)
     item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
     self._listModel.appendRow(item)
     self.setSelectionModified(False)
     return item
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:9,代码来源:OWPIPAx.py

示例4: _sum_item

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def _sum_item(value, border=""):
     item = QStandardItem()
     item.setData(value, Qt.DisplayRole)
     item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
     item.setFlags(Qt.ItemIsEnabled)
     item.setFont(bold_font)
     item.setData(border, BorderRole)
     item.setData(QColor(192, 192, 192), BorderColorRole)
     return item
开发者ID:astaric,项目名称:orange3,代码行数:11,代码来源:owconfusionmatrix.py

示例5: set_dict

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def set_dict(self, dict):
     self._dict = dict
     self.clear()
     self.setHorizontalHeaderLabels(["Key", "Value"])
     for key, value in sorted(dict.items()):
         key_item = QStandardItem(str(key))
         value_item = QStandardItem(str(value))
         key_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
         value_item.setFlags(value_item.flags() | Qt.ItemIsEditable)
         self.appendRow([key_item, value_item])
开发者ID:RachitKansal,项目名称:orange3,代码行数:12,代码来源:oweditdomain.py

示例6: set_dict

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def set_dict(self, dict):
     # type: (Dict[str, str]) -> None
     self._dict = dict
     self.setRowCount(0)
     for key, value in sorted(dict.items()):
         key_item = QStandardItem(key)
         value_item = QStandardItem(value)
         key_item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
         value_item.setFlags(value_item.flags() | Qt.ItemIsEditable)
         self.appendRow([key_item, value_item])
开发者ID:lanzagar,项目名称:orange3,代码行数:12,代码来源:oweditdomain.py

示例7: _widget_desc_to_std_item

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def _widget_desc_to_std_item(self, desc, category):
        """
        Create a QStandardItem for the widget description.
        """
        item = QStandardItem(desc.name)
        item.setText(desc.name)

        if desc.icon:
            icon = desc.icon
        else:
            icon = "icons/default-widget.svg"

        icon = icon_loader.from_description(desc).get(icon)
        item.setIcon(icon)

        # This should be inherited from the category.
        background = None
        if desc.background:
            background = desc.background
        elif category.background:
            background = category.background
        else:
            background = DEFAULT_COLOR

        if background is not None:
            background = NAMED_COLORS.get(background, background)
            brush = QBrush(QColor(background))
            item.setData(brush, self.BACKGROUND_ROLE)

        tooltip = tooltip_helper(desc)
        style = "ul { margin-top: 1px; margin-bottom: 1px; }"
        tooltip = TOOLTIP_TEMPLATE.format(style=style, tooltip=tooltip)
        item.setToolTip(tooltip)
        item.setWhatsThis(whats_this_helper(desc))
        item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        item.setData(desc, self.WIDGET_DESC_ROLE)

        # Create the action for the widget_item
        action = self.create_action_for_item(item)
        item.setData(action, self.WIDGET_ACTION_ROLE)
        return item
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:43,代码来源:qt.py

示例8: createRow

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def createRow(item):
        # type: (Item) -> List[QStandardItem]
        if isinstance(item, Installed):
            installed = True
            ins, dist = item.installable, item.local
            name = dist.project_name
            summary = get_dist_meta(dist).get("Summary", "")
            version = ins.version if ins is not None else dist.version
            item_is_core = item.required
        else:
            installed = False
            ins = item.installable
            dist = None
            name = ins.name
            summary = ins.summary
            version = ins.version
            item_is_core = False

        updatable = is_updatable(item)

        item1 = QStandardItem()
        item1.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                       Qt.ItemIsUserCheckable |
                       (Qt.ItemIsUserTristate if updatable else 0))
        item1.setEnabled(not (item_is_core and not updatable))
        item1.setData(item_is_core, HasConstraintRole)

        if installed and updatable:
            item1.setCheckState(Qt.PartiallyChecked)
        elif installed:
            item1.setCheckState(Qt.Checked)
        else:
            item1.setCheckState(Qt.Unchecked)
        item1.setData(item, Qt.UserRole)

        item2 = QStandardItem(name)
        item2.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        item2.setToolTip(summary)
        item2.setData(item, Qt.UserRole)

        if updatable:
            version = "{} < {}".format(dist.version, ins.version)

        item3 = QStandardItem(version)
        item3.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        item4 = QStandardItem()
        item4.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

        return [item1, item2, item3, item4]
开发者ID:ales-erjavec,项目名称:orange-canvas,代码行数:52,代码来源:addons.py

示例9: addItem

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def addItem(self, *args):
     """ Add a new entry in the list
     """
     item = QStandardItem(*args)
     item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
     self._listView.model().appendRow(item)
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:8,代码来源:OWPIPAx.py

示例10: _onAddAction

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
 def _onAddAction(self):
     item = QStandardItem("")
     item.setFlags(item.flags() ^ Qt.ItemIsDropEnabled)
     self._listView.model().appendRow(item)
     self._listView.setCurrentIndex(item.index())
     self._listView.edit(item.index())
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:8,代码来源:OWPIPAx.py

示例11: set_groups

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def set_groups(self, keys, groups, relevant_keys, relevant_items,
                   all_values, uniquepos):
        """Set the current data groups and update the Group widget
        """
        layout = QVBoxLayout()
        header_widths = []
        header_views = []
        palette = self.palette()
        all_values = all_values.keys()

        def for_print(rd):
            attrs = []
            for d in rd:
                attr = Orange.data.ContinuousVariable(next(inactive_name_gen))
                attr.attributes.update(d)
                attrs.append(attr)
            return Orange.data.Domain(attrs, None)

        for separatev, domain in [(None, for_print(relevant_items))] + groups:
            label = None
            if separatev is not None:
                ann_vals = " <b>|</b> ".join(["<b>{0}</b> = {1}".format(key,val) \
                     for key, val in zip(keys, separatev)])
                label = QLabel(ann_vals)

            model = QStandardItemModel()
            for i, attr in enumerate(domain.attributes):
                item = QStandardItem()
                if separatev is not None:
                    isunique = uniquepos[separatev][i]
                else:
                    isunique = all(a[i] for a in uniquepos.values())

                if str(attr.name).startswith("!!missing "):  # TODO: Change this to not depend on name
                    header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \
                                   for key in all_values if key not in relevant_items[i]]
                    header_text = "\n".join(header_text) if header_text else "Empty"
                    item.setData(header_text, Qt.DisplayRole)
                    item.setFlags(Qt.NoItemFlags)
                    item.setData(QColor(Qt.red), Qt.ForegroundRole)
                    item.setData(palette.color(QPalette.Disabled, QPalette.Window), Qt.BackgroundRole)
                    item.setData("Missing feature.", Qt.ToolTipRole)
                elif str(attr.name).startswith("!!inactive "):
                    header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \
                                   for key in all_values if key in relevant_items[i]]
                    header_text = "\n".join(header_text) if header_text else "No descriptor"
                    item.setData(header_text, Qt.DisplayRole)
                    item.setData(palette.color(QPalette.Disabled, QPalette.Window), Qt.BackgroundRole)
                else:
                    header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \
                                   for key in all_values if key not in relevant_items[i]]
                    header_text = "\n".join(header_text) if header_text else "Empty"
                    item.setData(header_text, Qt.DisplayRole)
                    item.setData(attr.name, Qt.ToolTipRole)

                if not isunique:
                    item.setData(QColor(Qt.red), Qt.ForegroundRole)

                model.setHorizontalHeaderItem(i, item)
            attr_count = len(domain.attributes)
            view = MyHeaderView(Qt.Horizontal)
            view.setResizeMode(QHeaderView.Fixed)
            view.setModel(model)
            hint = view.sizeHint()
            view.setMaximumHeight(hint.height())

            widths = [view.sectionSizeHint(i) for i in range(attr_count)]
            header_widths.append(widths)
            header_views.append(view)

            if label:
                layout.addWidget(label)
            layout.addWidget(view)
            layout.addSpacing(8)

        # Make all header sections the same width
        width_sum = 0
        max_header_count = max([h.count() for h in header_views])
        for i in range(max_header_count):
            max_width = max([w[i] for w in header_widths if i < len(w)] or [0])
            for view in header_views:
                if i < view.count():
                    view.resizeSection(i, max_width)
            width_sum += max_width + 2

        for h in header_views:
            h.setMinimumWidth(h.length() + 4)

        widget = QWidget()
        widget.setLayout(layout)
        widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum)
        layout.activate()

        max_width = max(h.length() for h in header_views) + 20

        left, _, right, _ = self.getContentsMargins()
        widget.setMinimumWidth(width_sum)
        widget.setMinimumWidth(max_width + left + right)
        self.groups_scroll_area.setWidget(widget)
开发者ID:JakaKokosar,项目名称:orange-bio,代码行数:101,代码来源:OWGenotypeDistances.py

示例12: set_items

# 需要导入模块: from AnyQt.QtGui import QStandardItem [as 别名]
# 或者: from AnyQt.QtGui.QStandardItem import setFlags [as 别名]
    def set_items(self, items):
        # type: (List[Item]) -> None
        self.__items = items
        model = self.__model
        model.setRowCount(0)

        for item in items:
            if isinstance(item, Installed):
                installed = True
                ins, dist = item
                name = dist.project_name
                summary = get_dist_meta(dist).get("Summary", "")
                version = ins.version if ins is not None else dist.version
            else:
                installed = False
                (ins,) = item
                dist = None
                name = ins.name
                summary = ins.summary
                version = ins.version

            updatable = is_updatable(item)

            item1 = QStandardItem()
            item1.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable |
                           Qt.ItemIsUserCheckable |
                           (Qt.ItemIsTristate if updatable else 0))

            if installed and updatable:
                item1.setCheckState(Qt.PartiallyChecked)
            elif installed:
                item1.setCheckState(Qt.Checked)
            else:
                item1.setCheckState(Qt.Unchecked)
            item1.setData(item, Qt.UserRole)

            item2 = QStandardItem(cleanup(name))
            item2.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            item2.setToolTip(summary)
            item2.setData(item, Qt.UserRole)

            if updatable:
                version = "{} < {}".format(dist.version, ins.version)

            item3 = QStandardItem(version)
            item3.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

            item4 = QStandardItem()
            item4.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)

            model.appendRow([item1, item2, item3, item4])

        model.sort(1)

        self.__view.resizeColumnToContents(0)
        self.__view.setColumnWidth(
            1, max(150, self.__view.sizeHintForColumn(1)))
        self.__view.setColumnWidth(
            2, max(150, self.__view.sizeHintForColumn(2)))

        if self.__items:
            self.__view.selectionModel().select(
                self.__view.model().index(0, 0),
                QItemSelectionModel.Select | QItemSelectionModel.Rows
            )
        self.__proxy.sort(1)  # sorting list of add-ons in alphabetical order
开发者ID:PrimozGodec,项目名称:orange3,代码行数:68,代码来源:addons.py


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