當前位置: 首頁>>代碼示例>>Python>>正文


Python QListWidget.currentIndex方法代碼示例

本文整理匯總了Python中PySide.QtGui.QListWidget.currentIndex方法的典型用法代碼示例。如果您正苦於以下問題:Python QListWidget.currentIndex方法的具體用法?Python QListWidget.currentIndex怎麽用?Python QListWidget.currentIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySide.QtGui.QListWidget的用法示例。


在下文中一共展示了QListWidget.currentIndex方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: ModelDialog

# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import currentIndex [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.currentIndex方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。