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


Python QListWidgetItem.setText方法代码示例

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


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

示例1: setter

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setText [as 别名]
 def setter(w, val):
     order_map = {x:i for i, x in enumerate(val)}
     items = list(w.defaults)
     limit = len(items)
     items.sort(key=lambda x:order_map.get(x, limit))
     w.clear()
     for x in items:
         i = QListWidgetItem(w)
         i.setText(x)
         i.setFlags(i.flags() | Qt.ItemIsDragEnabled)
开发者ID:HaraldGustafsson,项目名称:calibre,代码行数:12,代码来源:preferences.py

示例2: accept

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setText [as 别名]

#.........这里部分代码省略.........
            return self.simple_error('', _('No column heading was provided'))

        db = self.parent.gui.library_view.model().db
        key = db.field_metadata.custom_field_prefix+col
        bad_col = False
        if key in self.parent.custcols:
            if not self.editing_col or \
                    self.parent.custcols[key]['colnum'] != self.orig_column_number:
                bad_col = True
        if bad_col:
            return self.simple_error('', _('The lookup name %s is already used')%col)

        bad_head = False
        for t in self.parent.custcols:
            if self.parent.custcols[t]['name'] == col_heading:
                if not self.editing_col or \
                        self.parent.custcols[t]['colnum'] != self.orig_column_number:
                    bad_head = True
        for t in self.standard_colheads:
            if self.standard_colheads[t] == col_heading:
                bad_head = True
        if bad_head:
            return self.simple_error('', _('The heading %s is already used')%col_heading)

        display_dict = {}

        if col_type == 'datetime':
            if unicode(self.date_format_box.text()).strip():
                display_dict = {'date_format':unicode(self.date_format_box.text()).strip()}
            else:
                display_dict = {'date_format': None}
        elif col_type == 'composite':
            if not unicode(self.composite_box.text()).strip():
                return self.simple_error('', _('You must enter a template for'
                    ' composite columns'))
            display_dict = {'composite_template':unicode(self.composite_box.text()).strip(),
                            'composite_sort': ['text', 'number', 'date', 'bool']
                                        [self.composite_sort_by.currentIndex()],
                            'make_category': self.composite_make_category.isChecked(),
                            'contains_html': self.composite_contains_html.isChecked(),
                        }
        elif col_type == 'enumeration':
            if not unicode(self.enum_box.text()).strip():
                return self.simple_error('', _('You must enter at least one'
                    ' value for enumeration columns'))
            l = [v.strip() for v in unicode(self.enum_box.text()).split(',') if v.strip()]
            l_lower = [v.lower() for v in l]
            for i,v in enumerate(l_lower):
                if v in l_lower[i+1:]:
                    return self.simple_error('', _('The value "{0}" is in the '
                    'list more than once, perhaps with different case').format(l[i]))
            c = unicode(self.enum_colors.text())
            if c:
                c = [v.strip() for v in unicode(self.enum_colors.text()).split(',')]
            else:
                c = []
            if len(c) != 0 and len(c) != len(l):
                return self.simple_error('', _('The colors box must be empty or '
                'contain the same number of items as the value box'))
            for tc in c:
                if tc not in QColor.colorNames():
                    return self.simple_error('',
                            _('The color {0} is unknown').format(tc))

            display_dict = {'enum_values': l, 'enum_colors': c}
        elif col_type == 'text' and is_multiple:
            display_dict = {'is_names': self.is_names.isChecked()}
        elif col_type in ['int', 'float']:
            if unicode(self.number_format_box.text()).strip():
                display_dict = {'number_format':unicode(self.number_format_box.text()).strip()}
            else:
                display_dict = {'number_format': None}

        if col_type in ['text', 'composite', 'enumeration'] and not is_multiple:
            display_dict['use_decorations'] = self.use_decorations.checkState()

        if not self.editing_col:
            self.parent.custcols[key] = {
                    'label':col,
                    'name':col_heading,
                    'datatype':col_type,
                    'display':display_dict,
                    'normalized':None,
                    'colnum':None,
                    'is_multiple':is_multiple,
                }
            item = QListWidgetItem(col_heading, self.parent.opt_columns)
            item.setData(Qt.UserRole, QVariant(key))
            item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable|Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked)
        else:
            idx = self.parent.opt_columns.currentRow()
            item = self.parent.opt_columns.item(idx)
            item.setText(col_heading)
            self.parent.custcols[self.orig_column_name]['label'] = col
            self.parent.custcols[self.orig_column_name]['name'] = col_heading
            self.parent.custcols[self.orig_column_name]['display'].update(display_dict)
            self.parent.custcols[self.orig_column_name]['*edited'] = True
            self.parent.custcols[self.orig_column_name]['*must_restart'] = True
        QDialog.accept(self)
开发者ID:Eksmo,项目名称:calibre,代码行数:104,代码来源:create_custom_column.py

示例3: display

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setText [as 别名]
    def display(self, statsView):
        """
        Display the statistics in the listview widget 'statsView'
        """
        # Subtract singlets from total number of atoms
        self.num_atoms = self.natoms - self.nsinglets

        item = QListWidgetItem()
        item.setText("Measure Dihedral:" + str(self.num_mdihedral))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Measure Angle:" + str(self.num_mangle))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Measure Distance:" + str(self.num_mdistance))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Grid Plane:" + str(self.num_gridplane))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("ESP Image:" + str(self.num_espimage))
        statsView.addItem(item)

        item = QListWidgetItem()
        if sys.platform == "win32":
            item.setText("PC GAMESS:" + str(self.ngamess))
        else:
            item.setText("GAMESS:" + str(self.ngamess))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Thermometers:" + str(self.nthermos))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Thermostats:" + str(self.nstats))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Anchors:" + str(self.nanchors))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Linear Motors:" + str(self.nlmotors))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Rotary Motors:" + str(self.nrmotors))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Groups:" + str(self.ngroups))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Bondpoints:" + str(self.nsinglets))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Atoms:" + str(self.num_atoms))
        statsView.addItem(item)

        item = QListWidgetItem()
        item.setText("Chunks:" + str(self.nchunks))
        statsView.addItem(item)
开发者ID:elfion,项目名称:nanoengineer,代码行数:71,代码来源:GroupProp.py

示例4: accept

# 需要导入模块: from PyQt4.Qt import QListWidgetItem [as 别名]
# 或者: from PyQt4.Qt.QListWidgetItem import setText [as 别名]

#.........这里部分代码省略.........
        if not col_heading:
            return self.simple_error("", _("No column heading was provided"))

        db = self.parent.gui.library_view.model().db
        key = db.field_metadata.custom_field_prefix + col
        bad_col = False
        if key in self.parent.custcols:
            if not self.editing_col or self.parent.custcols[key]["colnum"] != self.orig_column_number:
                bad_col = True
        if bad_col:
            return self.simple_error("", _("The lookup name %s is already used") % col)

        bad_head = False
        for t in self.parent.custcols:
            if self.parent.custcols[t]["name"] == col_heading:
                if not self.editing_col or self.parent.custcols[t]["colnum"] != self.orig_column_number:
                    bad_head = True
        for t in self.standard_colheads:
            if self.standard_colheads[t] == col_heading:
                bad_head = True
        if bad_head:
            return self.simple_error("", _("The heading %s is already used") % col_heading)

        display_dict = {}

        if col_type == "datetime":
            if unicode(self.date_format_box.text()).strip():
                display_dict = {"date_format": unicode(self.date_format_box.text()).strip()}
            else:
                display_dict = {"date_format": None}
        elif col_type == "composite":
            if not unicode(self.composite_box.text()).strip():
                return self.simple_error("", _("You must enter a template for" " composite columns"))
            display_dict = {
                "composite_template": unicode(self.composite_box.text()).strip(),
                "composite_sort": ["text", "number", "date", "bool"][self.composite_sort_by.currentIndex()],
                "make_category": self.composite_make_category.isChecked(),
                "contains_html": self.composite_contains_html.isChecked(),
            }
        elif col_type == "enumeration":
            if not unicode(self.enum_box.text()).strip():
                return self.simple_error("", _("You must enter at least one" " value for enumeration columns"))
            l = [v.strip() for v in unicode(self.enum_box.text()).split(",") if v.strip()]
            l_lower = [v.lower() for v in l]
            for i, v in enumerate(l_lower):
                if v in l_lower[i + 1 :]:
                    return self.simple_error(
                        "",
                        _('The value "{0}" is in the ' "list more than once, perhaps with different case").format(l[i]),
                    )
            c = unicode(self.enum_colors.text())
            if c:
                c = [v.strip() for v in unicode(self.enum_colors.text()).split(",")]
            else:
                c = []
            if len(c) != 0 and len(c) != len(l):
                return self.simple_error(
                    "", _("The colors box must be empty or " "contain the same number of items as the value box")
                )
            for tc in c:
                if tc not in QColor.colorNames():
                    return self.simple_error("", _("The color {0} is unknown").format(tc))

            display_dict = {"enum_values": l, "enum_colors": c}
        elif col_type == "text" and is_multiple:
            display_dict = {"is_names": self.is_names.isChecked()}
        elif col_type in ["int", "float"]:
            if unicode(self.number_format_box.text()).strip():
                display_dict = {"number_format": unicode(self.number_format_box.text()).strip()}
            else:
                display_dict = {"number_format": None}

        if col_type in ["text", "composite", "enumeration"] and not is_multiple:
            display_dict["use_decorations"] = self.use_decorations.checkState()

        if not self.editing_col:
            self.parent.custcols[key] = {
                "label": col,
                "name": col_heading,
                "datatype": col_type,
                "display": display_dict,
                "normalized": None,
                "colnum": None,
                "is_multiple": is_multiple,
            }
            item = QListWidgetItem(col_heading, self.parent.opt_columns)
            item.setData(Qt.UserRole, QVariant(key))
            item.setData(Qt.DecorationRole, QVariant(QIcon(I("column.png"))))
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsSelectable)
            item.setCheckState(Qt.Checked)
        else:
            idx = self.parent.opt_columns.currentRow()
            item = self.parent.opt_columns.item(idx)
            item.setText(col_heading)
            self.parent.custcols[self.orig_column_name]["label"] = col
            self.parent.custcols[self.orig_column_name]["name"] = col_heading
            self.parent.custcols[self.orig_column_name]["display"].update(display_dict)
            self.parent.custcols[self.orig_column_name]["*edited"] = True
            self.parent.custcols[self.orig_column_name]["*must_restart"] = True
        QDialog.accept(self)
开发者ID:bjhemens,项目名称:calibre,代码行数:104,代码来源:create_custom_column.py


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