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


Python QDoubleSpinBox.text方法代码示例

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


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

示例1: BaseSectionWidget

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import text [as 别名]
class BaseSectionWidget(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.resize(400,80)

        self.sectionNameEdit = QLineEdit(self)
        self.sectionNameEdit.setGeometry(QRect(0,5,110,30))
        self.sectionNameEdit.setPlaceholderText("Section name")
        self.sectionNameEdit.setToolTip("Name of new section")

        self.sizeEdit = QDoubleSpinBox(self)
        self.sizeEdit.setGeometry(QRect(115,5,65,30))
        self.sizeEdit.setMaximum(100.0)
        self.sizeEdit.setToolTip("Size of section in percent")

        self.colorLabel = ColorChooser(self)
        self.colorLabel.setGeometry(QRect(185,8,25,25))

        self.displayedNameCheckBox = QCheckBox(self)
        self.displayedNameCheckBox.setGeometry(215, 5, 185, 30)
        self.displayedNameCheckBox.setText("Change displayed name")
        self.displayedNameCheckBox.setStyleSheet("font-size:11px;")

        self.displayedNameEdit = QLineEdit(self)
        self.displayedNameEdit.setGeometry(QRect(235,5,120,30))
        self.displayedNameEdit.setPlaceholderText("Displayed name")
        self.displayedNameEdit.setToolTip("Displayed name of new section")
        self.displayedNameEdit.setVisible(False)

        self.removeButton = QPushButton(self)
        self.removeButton.setGeometry(QRect(385,5,35,30))
        self.removeButton.setToolTip("Remove section")
        pixmap = QPixmap("./removeIcon.png")
        buttonIcon = QIcon(pixmap)
        self.removeButton.setIcon(buttonIcon)
        self.removeButton.setIconSize(QSize(25,25))

        self.connect(self.displayedNameCheckBox, QtCore.SIGNAL("clicked()"), self.changeDisplayedName)
        self.connect(self.removeButton, QtCore.SIGNAL("clicked()"), QtCore.SIGNAL("remove()"))
        self.connect(self.sizeEdit, QtCore.SIGNAL("valueChanged(double)"), self.changeSizeValue)

    def changeSizeValue(self):
        self.emit(QtCore.SIGNAL("sizeValueChanged(QWidget*)"), self)

    def changeDisplayedName(self):
        if self.displayedNameCheckBox.isChecked():
            self.displayedNameEdit.setVisible(True)
            self.displayedNameCheckBox.setText("")
        else:
            self.displayedNameEdit.setVisible((False))
            self.displayedNameCheckBox.setText("Change displayed name")

    def getName(self):
        return self.sectionNameEdit.text()

    def setSize(self, size):
        self.sizeEdit.setValue(size)

    def getSize(self):
        return self.sizeEdit.value()

    def getSectionData(self):
        name = self.sectionNameEdit.text()
        size = self.sizeEdit.text()
        color = self.colorLabel.getSelectedColor()
        displayedNameFlag = self.displayedNameCheckBox.isChecked()
        displayedName = self.displayedNameEdit.text()
        return [name, size, color, displayedNameFlag, displayedName]
开发者ID:trivelt,项目名称:app-solaris-svgmanipulator,代码行数:70,代码来源:BaseSectionWidget.py

示例2: ModifyPickerPropertiesMenu

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import text [as 别名]
class ModifyPickerPropertiesMenu(QDialog):

    def __init__(self, data, win_parent=None):
        self.win_parent = win_parent

        self._size = data['size'] * 100.
        self.out_data = data
        self.dim_max = data['dim_max']

        QDialog.__init__(self, win_parent)
        self.setWindowTitle('Modify Picker Properties')
        self.create_widgets()
        self.create_layout()
        self.set_connections()
        width = 260
        height = 130
        self.resize(width, height)
        #self.show()

    def create_widgets(self):
        # Size
        self.size = QLabel("Percent of Screen Size:")
        self.size_edit = QDoubleSpinBox(self)
        self.size_edit.setRange(0., 10.)

        log_dim = log10(self.dim_max)
        decimals = int(ceil(abs(log_dim)))

        decimals = max(3, decimals)
        self.size_edit.setDecimals(decimals)
        self.size_edit.setSingleStep(10. / 5000.)
        self.size_edit.setValue(self._size)

        # closing
        #self.apply_button = QPushButton("Apply")
        #self.ok_button = QPushButton("OK")
        self.cancel_button = QPushButton("Close")

    def create_layout(self):
        grid = QGridLayout()

        grid.addWidget(self.size, 1, 0)
        grid.addWidget(self.size_edit, 1, 1)

        ok_cancel_box = QHBoxLayout()
        #ok_cancel_box.addWidget(self.apply_button)
        #ok_cancel_box.addWidget(self.ok_button)
        ok_cancel_box.addWidget(self.cancel_button)

        vbox = QVBoxLayout()
        vbox.addLayout(grid)

        vbox.addStretch()
        vbox.addLayout(ok_cancel_box)
        self.setLayout(vbox)
        self.layout()

    #def on_color(self):
        #pass

    def set_connections(self):
        self.size_edit.valueChanged.connect(self.on_size)
        if qt_version == 4:
            self.connect(self.size_edit, QtCore.SIGNAL('editingFinished()'), self.on_size)
            self.connect(self.size_edit, QtCore.SIGNAL('valueChanged()'), self.on_size)
            self.connect(self.size_edit, QtCore.SIGNAL('clicked()'), self.on_size)

            #self.connect(self.apply_button, QtCore.SIGNAL('clicked()'), self.on_apply)
            #self.connect(self.ok_button, QtCore.SIGNAL('clicked()'), self.on_ok)
            self.connect(self.cancel_button, QtCore.SIGNAL('clicked()'), self.on_cancel)
            self.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)
        else:
            self.size_edit.editingFinished.connect(self.on_size)
            self.size_edit.valueChanged.connect(self.on_size)
            ## ??? clicked

            self.cancel_button.clicked.connect(self.on_cancel)
            #self.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)


    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Escape:
            self.close()

    def closeEvent(self, event):
        self.out_data['close'] = True
        event.accept()

    def on_size(self):
        self._size = float(self.size_edit.text())
        self.on_apply(force=True)

    @staticmethod
    def check_float(cell):
        text = cell.text()
        value = float(text)
        return value, True

    def on_validate(self):
        size_value, flag0 = self.check_float(self.size_edit)
#.........这里部分代码省略.........
开发者ID:hurlei,项目名称:pyNastran,代码行数:103,代码来源:modify_picker_properties.py

示例3: ModifyLabelPropertiesMenu

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import text [as 别名]

#.........这里部分代码省略.........

        col = QColorDialog.getColor(QtGui.QColor(*rgb_color_ints), self,
                                    "Choose a label color")
        if col.isValid():
            float_color = col.getRgbF()[:3]  # floats
            self.int_color = [int(colori * 255) for colori in float_color]
            self.float_color = float_color

            assert isinstance(self.float_color[0], float), self.float_color
            assert isinstance(self.int_color[0], int), self.int_color

            self.color_edit.setStyleSheet("QPushButton {"
                                          "background-color: rgb(%s, %s, %s);" % tuple(self.int_color) +
                                          #"border:1px solid rgb(255, 170, 255); "
                                          "}")
        self.on_apply(force=True)

    #def on_color(self):
        #pass

    def set_connections(self):
        self.size_edit.valueChanged.connect(self.on_size)

        if qt_version == 4:
            self.connect(self.size_edit, QtCore.SIGNAL('editingFinished()'), self.on_size)
            self.connect(self.size_edit, QtCore.SIGNAL('valueChanged()'), self.on_size)
            self.connect(self.size_edit, QtCore.SIGNAL('clicked()'), self.on_size)
            self.connect(self.color_edit, QtCore.SIGNAL('clicked()'), self.on_color)

            #self.connect(self.apply_button, QtCore.SIGNAL('clicked()'), self.on_apply)
            #self.connect(self.ok_button, QtCore.SIGNAL('clicked()'), self.on_ok)
            self.connect(self.cancel_button, QtCore.SIGNAL('clicked()'), self.on_cancel)
            self.connect(self, QtCore.SIGNAL('triggered()'), self.closeEvent)
        else:
            self.size_edit.editingFinished.connect(self.on_size)
            self.size_edit.valueChanged.connect(self.on_size)
            #self.size_edit.clicked
            self.color_edit.clicked.connect(self.on_color)
            self.cancel_button.clicked.connect(self.on_cancel)
            # closeEvent

    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Escape:
            self.close()

    def closeEvent(self, event):
        self.out_data['close'] = True
        event.accept()

    def on_size(self):
        self._size = float(self.size_edit.text())
        self.on_apply(force=True)
        #self.min_edit.setText(str(self._default_min))
        #self.min_edit.setStyleSheet("QLineEdit{background: white;}")

    @staticmethod
    def check_float(cell):
        text = cell.text()
        value = float(text)
        return value, True
        #try:
            #value = eval_float_from_string(text)
            #cell.setStyleSheet("QLineEdit{background: white;}")
            #return value, True
        #except ValueError:
            #cell.setStyleSheet("QLineEdit{background: red;}")
            #return None, False

    def on_validate(self):
        size_value, flag0 = self.check_float(self.size_edit)
        assert isinstance(self.float_color[0], float), self.float_color
        assert isinstance(self.int_color[0], int), self.int_color

        if flag0:
            self._size = size_value
            #self.out_data['min'] = min(min_value, max_value)
            #self.out_data['max'] = max(min_value, max_value)
            self.out_data['clicked_ok'] = True
            return True
        return False

    def on_apply(self, force=False):
        passed = self.on_validate()
        if (passed or Force) and self.win_parent is not None:
            self.win_parent.set_labelsize_color(self._size, self.float_color)
        return passed

    def on_ok(self):
        self.out_data['clicked_ok'] = True
        self.out_data['clicked_cancel'] = False
        self.out_data['close'] = True
        passed = self.on_apply()
        if passed:
            self.close()
            #self.destroy()

    def on_cancel(self):
        self.out_data['clicked_cancel'] = True
        self.out_data['close'] = True
        self.close()
开发者ID:saullocastro,项目名称:pyNastran,代码行数:104,代码来源:modify_label_properties.py

示例4: OrbitCorrGeneral

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import text [as 别名]

#.........这里部分代码省略.........

        vbox1.addStretch()
        vbox1.addLayout(gbox)
        
        hbox1 = QtGui.QHBoxLayout()
        hbox1.addWidget(self.table, 2)
        hbox1.addLayout(vbox1, 0)
        self.setLayout(hbox1)

        self.connect(self.base_orbit_box,
                     SIGNAL("currentIndexChanged(QString)"), 
                     self.updateTargetOrbit)
        self.connect(self.repeatbox, SIGNAL("valueChanged(int)"),
                     self.progress.setMaximum)
        self.connect(self.table, SIGNAL("cellChanged (int, int)"),
                     self.updateBump)

        #self.updateTargetOrbit(self.base_orbit_box.currentText())

    def _update_current_orbit(self):
        pvx = [bpm.pv(field="x", handle="readback")[0] for bpm in self.bpms]
        pvy = [bpm.pv(field="y", handle="readback")[0] for bpm in self.bpms]
        self.x0 = [float(v) if v.ok else np.nan for v in catools.caget(pvx)]
        self.y0 = [float(v) if v.ok else np.nan for v in catools.caget(pvy)]

    def resetBumps(self):
        jx0, jy0 = 5, 6
        for i in range(self.table.rowCount()):
            self.table.item(i, jx0).setData(Qt.DisplayRole, str(0.0))
            self.table.item(i, jy0).setData(Qt.DisplayRole, str(0.0))
        #self.updateTargetOrbit(self.base_orbit_box.currentText())

    def call_apply(self):
        #print "apply the orbit"
        obt = []
        jx, jy = 7, 8
        for i in range(self.table.rowCount()):
            x1,err = self.table.item(i, jx).data(Qt.DisplayRole).toFloat()
            y1,err = self.table.item(i, jy).data(Qt.DisplayRole).toFloat()
            obt.append([x1, y1])

        self.correctOrbitBtn.setEnabled(False)
        nrepeat = self.repeatbox.value()
        kw = { "scale": float(self.scalebox.text()),
               "rcond": float(self.rcondbox.text()) }
        self.progress.setValue(0)
        QApplication.processEvents()
        for i in range(nrepeat):
            err, msg = setLocalBump(self.bpms, self.cors, obt, **kw)
            self.progress.setValue(i+1)
            QApplication.processEvents()
            if err != 0:
                QtGui.QMessageBox.critical(
                    self, "Local Orbit Bump", 
                    "ERROR: {0}\nAbort.".format(msg),
                    QtGui.QMessageBox.Ok)
                #self.progress.setValue(0)
                break
       
        self.correctOrbitBtn.setEnabled(True)

    def getTargetOrbit(self):
        x = [self.table.item(i,7).data(Qt.DisplayRole).toFloat()[0]
             for i in range(self.table.rowCount())]
        y = [self.table.item(i,8).data(Qt.DisplayRole).toFloat()[0]
             for i in range(self.table.rowCount())]
        return (self.sb, x), (self.sb, y)

    def updateTargetOrbit(self, baseobt):
        if baseobt == "All Zeros":
            jx0, jx1 = 5, 7
            jy0, jy1 = 6, 8
            for i in range(self.table.rowCount()):
                it0 = self.table.item(i, jx0)
                it1 = self.table.item(i, jx1)
                it1.setData(Qt.DisplayRole, it0.data(Qt.DisplayRole))
                it0 = self.table.item(i, jy0)
                it1 = self.table.item(i, jy1)
                it1.setData(Qt.DisplayRole, it0.data(Qt.DisplayRole))
        elif baseobt == "Current Orbit":
            self._update_current_orbit()
            jx0, jx1 = 5, 7
            jy0, jy1 = 6, 8
            for i in range(self.table.rowCount()):
                dx0,err = self.table.item(i, jx0).data(Qt.DisplayRole).toFloat()
                it = self.table.item(i, jx1)
                it.setData(Qt.DisplayRole, self.x0[i] + dx0)

                dy0,err = self.table.item(i, jy0).data(Qt.DisplayRole).toFloat()
                it = self.table.item(i, jy1)
                it.setData(Qt.DisplayRole, self.y0[i] + dy0)
        #self._update_orbit_plot()
        x, y = self.getTargetOrbit()
        self.emit(SIGNAL("targetOrbitChanged(PyQt_PyObject, PyQt_PyObject)"),
                  x, y)

    def updateBump(self, row, col):
        #print "updating ", row, col
        if col == 5 or col == 6:
            self.updateTargetOrbit(self.base_orbit_box.currentText())
开发者ID:ChannelFinder,项目名称:hla,代码行数:104,代码来源:orbitcorrdlg.py


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