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


Python QtGui.QStandardItem类代码示例

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


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

示例1: addSelection

 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,代码行数:7,代码来源:OWPIPAx.py

示例2: __init__

    def __init__(self, var, lc, widget_parent=None, widget=None):
        QWidget.__init__(self)

        self.list_view = QListView()
        text = []
        model = QStandardItemModel(self.list_view)
        for (i, val) in enumerate(var.values):
            item = QStandardItem(val)
            item.setCheckable(True)
            if i + 1 in lc:
                item.setCheckState(Qt.Checked)
                text.append(val)
            model.appendRow(item)
        model.itemChanged.connect(widget_parent.conditions_changed)
        self.list_view.setModel(model)

        layout = QGridLayout(self)
        layout.addWidget(self.list_view)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.adjustSize()
        self.setWindowFlags(Qt.Popup)

        self.widget = widget
        self.widget.desc_text = ', '.join(text)
        self.widget.set_text()
开发者ID:lanzagar,项目名称:orange3,代码行数:27,代码来源:owselectrows.py

示例3: list_docs

    def list_docs(self):
        """ List documents into the left scrolling area """
        search_keyword = self.filter_input.text().strip('|')
        try:
            reg = re.compile(search_keyword, re.IGNORECASE)
        except sre_constants.error:
            return

        def is_match(x):
            return not bool(search_keyword) or reg.search(x)

        self.output_mask.clear()
        self.doc_list_model.clear()

        for i, (doc, title, content) in enumerate(zip(self.corpus, self.corpus.titles,
                                                      self.corpus_docs)):
            if is_match(content):
                item = QStandardItem()
                item.setData(title, Qt.DisplayRole)
                item.setData(doc, Qt.UserRole)
                self.doc_list_model.appendRow(item)
                self.output_mask.append(i)

        if self.doc_list_model.rowCount() > 0:
            self.doc_list.selectRow(0)          # Select the first document
        else:
            self.doc_webview.setHtml('')
        self.commit()
开发者ID:biolab,项目名称:orange3-text,代码行数:28,代码来源:owcorpusviewer.py

示例4: _update_header

 def _update_header(self):
     # Set the correct horizontal header labels on the results_model.
     model = self.result_model
     model.setColumnCount(1 + len(self.scorers))
     for col, score in enumerate(self.scorers):
         item = QStandardItem(score.name)
         item.setToolTip(score.long_name)
         model.setHorizontalHeaderItem(col + 1, item)
     self._update_shown_columns()
开发者ID:benzei,项目名称:orange3,代码行数:9,代码来源:owtestlearners.py

示例5: row_for_state

 def row_for_state(self, score, state):
     """The row consists of attributes sorted by name; class is at the
     beginning, if present, so it's on the x-axis and not lost somewhere."""
     class_var = self.master.color_data.domain.class_var
     attrs = tuple(
         sorted((self.attr_ordering[x] for x in state),
                key=lambda attr: (1 - (attr is class_var), attr.name)))
     item = QStandardItem(", ".join(a.name for a in attrs))
     item.setData(attrs, self._AttrRole)
     return [item]
开发者ID:astaric,项目名称:orange3,代码行数:10,代码来源:owmosaic.py

示例6: color_palette_model

def color_palette_model(palettes, iconsize=QSize(64, 16)):
    model = QStandardItemModel()
    for name, palette in palettes:
        _, colors = max(palette.items())
        colors = [QColor(*c) for c in colors]
        item = QStandardItem(name)
        item.setIcon(QIcon(palette_pixmap(colors, iconsize)))
        item.setData(palette, Qt.UserRole)
        model.appendRow([item])
    return model
开发者ID:markotoplak,项目名称:orange-infrared,代码行数:10,代码来源:owhyper.py

示例7: RecentPath_asqstandarditem

def RecentPath_asqstandarditem(pathitem):
    icon_provider = QFileIconProvider()
    # basename of a normalized name (strip right path component separators)
    basename = os.path.basename(os.path.normpath(pathitem.abspath))
    item = QStandardItem(
        icon_provider.icon(QFileInfo(pathitem.abspath)),
        basename
    )
    item.setToolTip(pathitem.abspath)
    item.setData(pathitem, Qt.UserRole)
    return item
开发者ID:biolab,项目名称:orange3-imageanalytics,代码行数:11,代码来源:owimageimport.py

示例8: row_for_state

 def row_for_state(self, score, state):
     attrs = sorted((self.attrs[x] for x in state), key=attrgetter("name"))
     attrs_item = QStandardItem(
         "{}, {}".format(attrs[0].name, attrs[1].name))
     attrs_item.setData(attrs, self._AttrRole)
     attrs_item.setData(Qt.AlignLeft + Qt.AlignTop, Qt.TextAlignmentRole)
     correlation_item = QStandardItem("{:+.3f}".format(score[1]))
     correlation_item.setData(attrs, self._AttrRole)
     correlation_item.setData(
         self.NEGATIVE_COLOR if score[1] < 0 else self.POSITIVE_COLOR,
         gui.TableBarItem.BarColorRole)
     return [correlation_item, attrs_item]
开发者ID:lanzagar,项目名称:orange3,代码行数:12,代码来源:owcorrelations.py

示例9: item

 def item(value=None, tooltip=None, user=None):
     si = QStandardItem()
     if value is not None:
         si.setData(value, Qt.DisplayRole)
     if tooltip is not None:
         si.setData(tooltip, Qt.ToolTipRole)
     if user is not None:
         si.setData(user, Qt.UserRole)
     else:
         si.setData(value, Qt.UserRole)
     return si
开发者ID:markotoplak,项目名称:orange-bio,代码行数:11,代码来源:OWSetEnrichment.py

示例10: _initialize

    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,代码行数:28,代码来源:owpreprocess.py

示例11: __activated

 def __activated(self, index):
     item = self.preprocessors.itemFromIndex(index)
     action = item.data(DescriptionRole)
     item = QStandardItem()
     item.setData({}, ParametersRole)
     item.setData(action.description.title, Qt.DisplayRole)
     item.setData(action, DescriptionRole)
     self.preprocessormodel.appendRow([item])
开发者ID:benzei,项目名称:orange3,代码行数:8,代码来源:owpreprocess.py

示例12: show_results

    def show_results(self):
        minimize = self.SCORING_METHODS[self.scoring][2]
        k_scores = [(k, self.SCORING_METHODS[self.scoring][1](run)) for
                    k, run in self.optimization_runs]
        scores = list(zip(*k_scores))[1]
        if minimize:
            best_score, worst_score = min(scores), max(scores)
        else:
            best_score, worst_score = max(scores), min(scores)

        best_run = scores.index(best_score)
        score_span = (best_score - worst_score) or 1
        max_score = max(scores)
        nplaces = min(5, np.floor(abs(math.log(max(max_score, 1e-10)))) + 2)
        fmt = "{{:.{}f}}".format(int(nplaces))
        model = self.table_model
        model.setRowCount(len(k_scores))
        for i, (k, score) in enumerate(k_scores):
            item = model.item(i, 0)
            if item is None:
                item = QStandardItem()
            item.setData(k, Qt.DisplayRole)
            item.setTextAlignment(Qt.AlignCenter)
            model.setItem(i, 0, item)
            item = model.item(i, 1)
            if item is None:
                item = QStandardItem()
            item.setData(fmt.format(score) if not np.isnan(score) else 'out-of-memory error',
                         Qt.DisplayRole)
            bar_ratio = 0.95 * (score - worst_score) / score_span
            item.setData(bar_ratio, gui.TableBarItem.BarRole)
            model.setItem(i, 1, item)
        self.table_view.resizeRowsToContents()

        self.table_view.selectRow(best_run)
        self.table_view.show()
        if minimize:
            self.table_box.setTitle("Scoring (smaller is better)")
        else:
            self.table_box.setTitle("Scoring (bigger is better)")
        QTimer.singleShot(0, self.adjustSize)
开发者ID:RachitKansal,项目名称:orange3,代码行数:41,代码来源:owkmeans.py

示例13: set_dict

 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,代码行数:10,代码来源:oweditdomain.py

示例14: set_dict

 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,代码行数:10,代码来源:oweditdomain.py

示例15: list_docs

    def list_docs(self):
        """ List documents into the left scrolling area """
        if self.corpus_docs is None:
            return
        search_keyword = self.regexp_filter.strip('|')
        try:
            reg = re.compile(search_keyword, re.IGNORECASE)
        except sre_constants.error:
            return

        def is_match(x):
            return not bool(search_keyword) or reg.search(x)

        self.output_mask.clear()
        self.doc_list_model.clear()

        for i, (doc, title, content) in enumerate(zip(self.corpus, self.corpus.titles,
                                                      self.corpus_docs)):
            if is_match(content):
                item = QStandardItem()
                item.setData(title, Qt.DisplayRole)
                item.setData(doc, Qt.UserRole)
                self.doc_list_model.appendRow(item)
                self.output_mask.append(i)
开发者ID:s-alexey,项目名称:orange3-text,代码行数:24,代码来源:owcorpusviewer.py


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