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


Python QListWidget.itemFromIndex方法代码示例

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


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

示例1: ModelDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import itemFromIndex [as 别名]

#.........这里部分代码省略.........
        geogrp = QGroupBox('Geometry')
        geolay = QHBoxLayout()

        self.geometries = QListWidget()
        self.geometries.addItems(['{0} - {1}'.format(ind, geo.classname) for ind, geo in enumerate(self.mdl.segments)])

        geolay.addStretch()
        geolay.addWidget(self.geometries)

        edit_geo = QPushButton('Edit')
        edit_geo.clicked.connect(self.edit_geo)

        geolay.addWidget(edit_geo)

        geogrp.setLayout(geolay)

        btns = QHBoxLayout()

        save = QPushButton('Save')
        save.clicked.connect(self.save)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.close)
        self.status = QLabel('Model Edit Mode')

        btns.addWidget(self.status)
        btns.addStretch()
        btns.addWidget(save)
        btns.addWidget(cancel)

        mainlay = QVBoxLayout()
        mainlay.addWidget(grp)
        mainlay.addWidget(geogrp)
        mainlay.addLayout(btns)

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 400, 200)
        self.setWindowTitle('MSH Suite - {0}'.format(self.mdl.name))
        self.show()

    def edit_geo(self):
        ind = self.geometries.currentIndex()
        item = self.geometries.itemFromIndex(ind)
        if not item:
            return
        geo = item.text().split('-')
        index = int(geo[0].strip())
        geo = self.mdl.segments[index]
        if geo.classname in ('SegmentGeometry', 'ClothGeometry'):
            gd = GeometryDialog(self, geo)


    def show_uvs(self):
        di = misc_dialogs.DoubleInt(self.render_uvs, self, 'Width', 'Height', 512, 512)

    def render_uvs(self, width, height):
        if ('geo' in self.mdl.model_type) or self.mdl.model_type == 'cloth':
            uvv = UVViewer(self.mdl, width, height, self)

    def print_faces(self):
        segm = self.mdl.segments[0]
        print len(segm.faces)
        for face in segm.faces:
            print 'Face'
            print '\t{0}'.format(face.sides)
            print '\t{0}'.format(face.SIindices())

    def edit_bbox(self):
        self.bd = misc_dialogs.BBoxDialog(self.mdl.bbox, self.parent)

    def edit_collprim(self):
        self.dd = CollisionPrimDialog(self.mdl, self.parent)

    def edit_deformers(self):
        self.dd = DeformerDialog(self.mdl, self.parent)

    def edit_tran(self):
        et = misc_dialogs.TransformDialog(self.mdl.transform, self.parent)

    def name_changed(self):
        self.status.setText(' Remember: change parent of child models.')

    def validate(self):
        # Check parent.
        parent = self.controls['parent'].text()
        if parent:
            if not self.parent.mdlmanager.mdlcoll.by_name(parent):
                self.controls['parent'].setStyleSheet('QWidget { color: red}')
            else:
                self.controls['parent'].setStyleSheet('QWidget { color: black}')
            if parent == self.controls['name'].text():
                self.controls['parent'].setStyleSheet('QWidget { color: red}')
        else:
            self.controls['parent'].setStyleSheet('QWidget { color: black}')
        self.status.setText('Validate done.')

    def save(self):
        self.mdl.name = self.controls['name'].text().encode(STR_CODEC)
        self.mdl.parent = self.controls['parent'].text().encode(STR_CODEC)
        self.mdl.vis = self.controls['vis'].isChecked()
        self.close()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:104,代码来源:model_dialogs.py


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