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


Python QSpinBox.text方法代码示例

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


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

示例1: DoubleInt

# 需要导入模块: from PySide.QtGui import QSpinBox [as 别名]
# 或者: from PySide.QtGui.QSpinBox import text [as 别名]
class DoubleInt(QDialog):
    def __init__(self, cmd, parent=None, text_left='left', text_right='right',
                default1=0, default2=0):
        # cmd is a command which this dialog will call upon OKing.
        # The arguments are cmd(i1, i2), the two chosen ints.
        super(DoubleInt, self).__init__(parent)
        self.tr = text_right
        self.tl = text_left
        self.i1 = 0
        self.i2 = 0
        self.default1 = default1
        self.default2 = default2
        self.cmd = cmd
        self.initUI()

    def initUI(self):
        mainlay = QVBoxLayout()
        btns = QHBoxLayout()
        mainui = QGridLayout()

        mainlay.addLayout(mainui)
        mainlay.addLayout(btns)

        ok = QPushButton('OK')
        ok.clicked.connect(self.ok)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.close)

        btns.addStretch()
        btns.addWidget(ok)
        btns.addWidget(cancel)

        text1 = QLabel(self.tl)
        text2 = QLabel(self.tr)
        self.int1 = QSpinBox()
        self.int1.setMaximum(2048)
        self.int1.setMinimum(128)
        self.int1.setValue(self.default1)
        self.int2 = QSpinBox()
        self.int2.setMaximum(2048)
        self.int2.setMinimum(128)
        self.int2.setValue(self.default2)
        mainui.addWidget(text1, 0, 0)
        mainui.addWidget(text2, 0, 1)
        mainui.addWidget(self.int1, 1, 0)
        mainui.addWidget(self.int2, 1, 1)

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 200, 100)
        self.setWindowTitle('MSH Suite - Double Integer')
        self.show()

    def ok(self):
        self.i1 = int(self.int1.text())
        self.i2 = int(self.int2.text())
        self.cmd(self.i1, self.i2)
        self.close()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:59,代码来源:misc_dialogs.py

示例2: UVViewer

# 需要导入模块: from PySide.QtGui import QSpinBox [as 别名]
# 或者: from PySide.QtGui.QSpinBox import text [as 别名]
class UVViewer(QDialog):
    def __init__(self, model, w, h, parent=None):
        super(UVViewer, self).__init__(parent)
        self.w = w
        self.h = h
        self.mdl = model
        self.white_b = QBrush(Qt.white)
        self.black_b = QBrush(Qt.black)
        self.pen_width = 2
        self.initUI()

    def initUI(self):
        mainlay = QVBoxLayout()
        scn = QGraphicsScene(0, 0, self.w, self.h)

        self.view = QGraphicsView()
        self.view.setScene(scn)
        self.view.setSceneRect(QRectF(0, 0, self.w, self.h))
        self.view.setMaximumWidth(self.w)
        self.view.setMaximumHeight(self.h)

        mainlay.addWidget(self.view)

        btns = QHBoxLayout()
        btns.addStretch()

        self.pen_w = QSpinBox()
        self.pen_w.setValue(self.pen_width)
        redraw = QPushButton('Redraw')
        redraw.clicked.connect(self.draw_uvs)
        save = QPushButton('Save')
        save.clicked.connect(self.save)
        close = QPushButton('Close')
        close.clicked.connect(self.close)

        btns.addWidget(QLabel('Stroke Width'))
        btns.addWidget(self.pen_w)
        btns.addWidget(redraw)
        btns.addWidget(save)
        btns.addWidget(close)

        mainlay.addLayout(btns)

        self.draw_uvs()

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 512, 560)
        self.setWindowTitle('MSH Suite UV Viewer')
        self.show()

    def draw_uvs(self):
        self.img = QPixmap(QSize(self.w, self.h))
        pen = QPen()
        pen.setWidth(int(self.pen_w.text()))
        pen.setBrush(QBrush(Qt.white))
        pen.setColor(QColor('white'))
        painter = QPainter()
        painter.begin(self.img)
        painter.setPen(pen)
        coords = self.get_coords()
        for face in coords:
            for n in xrange(len(face) - 1):
                print face[n][0], face[n][1], face[n + 1][0], face[n + 1][1]
                painter.drawLine(face[n][0], face[n][1], face[n + 1][0], face[n + 1][1])
        painter.end()
        self.view.scene().addPixmap(self.img)

    def get_coords(self):
        coords = []
        for seg in self.mdl.segments:
            if seg.classname == 'SegmentGeometry':
                print 'doing stuff'
                vcoll = seg.vertices
                for face in seg.faces:
                    face_coords = []
                    for v in face.SIindices():
                        face_coords.append((vcoll[v].u * self.w, (1 - vcoll[v].v) * self.h))
                    face_coords.append((vcoll[face.vertices[0]].u * self.w,
                                        (1 - vcoll[face.vertices[0]].v) * self.h))
                    coords.append(face_coords)
                    #print face_coords
        return coords

    def save(self):
        filename, _ = QFileDialog.getSaveFileName(self, 'Save UV Mesh', os.getcwd(), 'PNG Files (*.png)')
        if not filename:
            return
        self.img.save(filename, 'PNG')
        self.close()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:91,代码来源:model_dialogs.py


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