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


Python QDoubleSpinBox.value方法代码示例

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


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

示例1: Form

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class Form(QDialog):
    def __init__(self, parent=None):
        super(Form, self).__init__(parent)
        
        self.label_amount = QLabel('Amount')
        self.spin_amount = QDoubleSpinBox()
        self.spin_amount.setRange(0, 10000000000)
        self.spin_amount.setPrefix('Rp. ')
        self.spin_amount.setSingleStep(100000)
        
        self.label_rate = QLabel('Rate')
        self.spin_rate = QDoubleSpinBox()
        self.spin_rate.setSuffix(' %')
        self.spin_rate.setSingleStep(0.1)
        self.spin_rate.setRange(0, 100)
        
        self.label_year = QLabel('Years')
        self.spin_year = QSpinBox()
        self.spin_year.setSuffix(' year')
        self.spin_year.setSingleStep(1)
        self.spin_year.setRange(0, 1000)
        self.spin_year.setValue(1)
        
        
        self.label_total_ = QLabel('Total')
        self.label_total = QLabel('Rp. 0.00')
        
        grid = QGridLayout()
        grid.addWidget(self.label_amount, 0, 0)
        grid.addWidget(self.spin_amount, 0, 1)
        grid.addWidget(self.label_rate, 1, 0)
        grid.addWidget(self.spin_rate, 1, 1)
        grid.addWidget(self.label_year, 2, 0)
        grid.addWidget(self.spin_year, 2, 1)
        grid.addWidget(self.label_total_, 3, 0)
        grid.addWidget(self.label_total, 3, 1)
        self.setLayout(grid)
        
        self.connect(self.spin_amount, SIGNAL('valueChanged(double)'), self.update_ui)
        self.connect(self.spin_rate, SIGNAL('valueChanged(double)'), self.update_ui)
        self.connect(self.spin_year, SIGNAL('valueChanged(int)'), self.update_ui)
        self.setWindowTitle('Interest')
    
    def update_ui(self):        
        amount = self.spin_amount.value()
        rate = self.spin_rate.value()
        year = self.spin_year.value()
        total = amount * (1 + rate / 100.0) ** year
        
        self.label_total.setText('Rp. %.2f' % total)
开发者ID:arifwn,项目名称:PyQt-Playground,代码行数:52,代码来源:compound_interest.py

示例2: ChangeConfLevelDlg

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class ChangeConfLevelDlg(QDialog):
    ''' Dialog for changing confidence level '''
    
    def __init__(self, previous_value=DEFAULT_CONF_LEVEL, parent=None):
        super(ChangeConfLevelDlg, self).__init__(parent)
        
        cl_label = QLabel("Global Confidence Level:")
        
        self.conf_level_spinbox = QDoubleSpinBox()
        self.conf_level_spinbox.setRange(50, 99.999 )
        self.conf_level_spinbox.setSingleStep(0.1)
        self.conf_level_spinbox.setSuffix(QString("%"))
        self.conf_level_spinbox.setValue(previous_value)
        self.conf_level_spinbox.setDecimals(1)
        
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        
        hlayout = QHBoxLayout()
        hlayout.addWidget(cl_label)
        hlayout.addWidget(self.conf_level_spinbox)
        vlayout = QVBoxLayout()
        vlayout.addLayout(hlayout)
        vlayout.addWidget(buttonBox)
        self.setLayout(vlayout)
        
        self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
        self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
        self.setWindowTitle("Change Confidence Level")
        
    def get_value(self):
        return self.conf_level_spinbox.value()
开发者ID:RavichandraMondreti,项目名称:OpenMeta-analyst-,代码行数:33,代码来源:conf_level_dialog.py

示例3: IntervalSpinner

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class IntervalSpinner(QWidget):
    def __init__(self, parent, min_=1, max_=1000, step=1, round_option=True):
        QWidget.__init__(self, parent)
        layout = QVBoxLayout(self)
        hlayout = QHBoxLayout()
        self.start = QDoubleSpinBox(self)
        self.start.setMinimum(min_)
        self.start.setMaximum(max_)
        self.end = QDoubleSpinBox(self)
        self.end.setMinimum(min_)
        self.end.setMaximum(max_)
        self.end.setValue(max_)
        self.start.setSingleStep(step)
        self.end.setSingleStep(step)

        self.start.valueChanged.connect(self.on_value_start_changed)
        self.end.valueChanged.connect(self.on_value_end_changed)

        hlayout.addWidget(self.start)
        hlayout.addWidget(self.end)
        layout.addLayout(hlayout)

        if round_option:
            self.integerCheckBox = QCheckBox("Round to integer values", self)
            layout.addWidget(self.integerCheckBox)

    def on_value_start_changed(self, val):
        if self.end.value() < val:
            self.end.setValue(val)

    def on_value_end_changed(self, val):
        if self.start.value() > val:
            self.start.setValue(val)

    def getMin(self):
        return self.start.value()

    def getMax(self):
        return self.end.value()

    def getRound(self):
        return self.integerCheckBox.isChecked()
开发者ID:javipalanca,项目名称:simso,代码行数:44,代码来源:TaskGenerator.py

示例4: AddNewWeight

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class AddNewWeight(AddNewDialog):
    def __init__(self, parent, item):
        AddNewDialog.__init__(self, parent)
        self.setText('Lisää uusi punnitus', 'Uusi punnitus')
        self.ui.lineEdit.hide()
        self.item = item
        self.priceSelector = QDoubleSpinBox(parent=self)
        self.priceSelector.setMaximum(999999)
        self.priceSelector.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self.ui.horizontalLayout.addWidget(self.priceSelector)
        self.hideComboBox()
    
    def saveCheck(self):
        if self.priceSelector.value() > 0:
            self.saveNewItem()
        
    def saveNewItem(self):
        item = SqlHandler.WeightControl(animal_id = self.item.id, weight=self.priceSelector.value())
        SqlHandler.addItem(self.session, item)
        print('WeightControl saveNweItem, ', item)
        self.parent().addAskedItem(item)
        self.closeDialog()
开发者ID:mape90,项目名称:VetApp,代码行数:24,代码来源:addNewDialog.py

示例5: DoubleSpinBox

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class DoubleSpinBox(QWidget):
    def __init__(self, id, text, **kwargs):
        QWidget.__init__(self)
        self.id = id
        self.widget = QDoubleSpinBox(**kwargs)
        label = QLabel(text)
        hbox = HBoxLayout()
        hbox.addWidget(label)
        hbox.addWidget(self.widget)
        self.setLayout(hbox)
        self.widget.setMaximum(999999999)
        self.widget.setMinimum(-999999999)

    def parameterValues(self):
        return {self.id:self.widget.value()}
开发者ID:karstenv,项目名称:manageR,代码行数:17,代码来源:plugins_dialog.py

示例6: StyleChooser

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

    def __init__(self, area_supported=False):
        QWidget.__init__(self)
        self._style = PlotStyle("StyleChooser Internal Style")
        self._styles = STYLES if area_supported else STYLES_LINE_ONLY

        self.setMinimumWidth(140)
        self.setMaximumHeight(25)

        layout = QHBoxLayout()
        layout.setMargin(0)
        layout.setSpacing(2)

        self.line_chooser = QComboBox()
        self.line_chooser.setToolTip("Select line style.")
        for style in self._styles:
            self.line_chooser.addItem(*style)

        self.marker_chooser = QComboBox()
        self.marker_chooser.setToolTip("Select marker style.")
        for marker in MARKERS:
            self.marker_chooser.addItem(*marker)

        self.thickness_spinner = QDoubleSpinBox()
        self.thickness_spinner.setToolTip("Line thickness")
        self.thickness_spinner.setMinimum(0.1)
        self.thickness_spinner.setDecimals(1)
        self.thickness_spinner.setSingleStep(0.1)

        self.size_spinner = QDoubleSpinBox()
        self.size_spinner.setToolTip("Marker Size")
        self.size_spinner.setMinimum(0.1)
        self.size_spinner.setDecimals(1)
        self.size_spinner.setSingleStep(0.1)

        layout.addWidget(self.line_chooser)
        layout.addWidget(self.thickness_spinner)
        layout.addWidget(self.marker_chooser)
        layout.addWidget(self.size_spinner)

        self.setLayout(layout)

        self.line_chooser.currentIndexChanged.connect(self._updateStyle)
        self.marker_chooser.currentIndexChanged.connect(self._updateStyle)
        self.thickness_spinner.valueChanged.connect(self._updateStyle)
        self.size_spinner.valueChanged.connect(self._updateStyle)

        self._updateLineStyleAndMarker(self._style.line_style, self._style.marker, self._style.width, self._style.size)
        self._layout = layout

    def getItemSizes(self):
        line_style_combo_width = self._layout.itemAt(0).sizeHint().width()
        thickness_spinner_width = self._layout.itemAt(1).sizeHint().width()
        marker_combo_width = self._layout.itemAt(2).sizeHint().width()
        size_spinner_width = self._layout.itemAt(3).sizeHint().width()
        return line_style_combo_width, thickness_spinner_width, marker_combo_width, size_spinner_width

    def _findLineStyleIndex(self, line_style):
        for index, style in enumerate(self._styles):
            if style[1] == line_style:
                return index
            elif style[1] is None and line_style == "":
                return index
        return -1

    def _findMarkerStyleIndex(self, marker):
        for index, style in enumerate(MARKERS):
            if style[1] == marker:
                return index
            elif style[1] is None and marker == "":
                return index
        return -1

    def _updateLineStyleAndMarker(self, line_style, marker, thickness, size):
        self.line_chooser.setCurrentIndex(self._findLineStyleIndex(line_style))
        self.marker_chooser.setCurrentIndex(self._findMarkerStyleIndex(marker))
        self.thickness_spinner.setValue(thickness)
        self.size_spinner.setValue(size)

    def _updateStyle(self):
        self.marker_chooser.setEnabled(self.line_chooser.currentText() != "Area")

        line_style = self.line_chooser.itemData(self.line_chooser.currentIndex())
        marker_style = self.marker_chooser.itemData(self.marker_chooser.currentIndex())
        thickness = float(self.thickness_spinner.value())
        size = float(self.size_spinner.value())

        self._style.line_style = str(line_style.toString())
        self._style.marker = str(marker_style.toString())
        self._style.width = thickness
        self._style.size = size

    def setStyle(self, style):
        """ @type style: PlotStyle """
        self._style.copyStyleFrom(style)
        self._updateLineStyleAndMarker(style.line_style, style.marker, style.width, style.size)

    def getStyle(self):
        """ @rtype: PlotStyle """
#.........这里部分代码省略.........
开发者ID:agchitu,项目名称:ert,代码行数:103,代码来源:style_chooser.py

示例7: DefaultSelectParameterWidget

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

    """Widget class for Default Select Parameter."""

    def __init__(self, parameter, parent=None):
        """Constructor

        :param parameter: A DefaultSelectParameter object.
        :type parameter: DefaultSelectParameter
        """
        super(DefaultSelectParameterWidget, self).__init__(parameter, parent)

        self.default_layout = QHBoxLayout()
        self.radio_button_layout = QHBoxLayout()
        self.radio_button_widget = QWidget()

        self.default_label = QLabel(tr('Default'))

        # Create radio button group
        self.default_input_button_group = QButtonGroup()

        # Define string enabler for radio button
        self.radio_button_enabler = self.input.itemData(0, Qt.UserRole)

        for i in range(len(self._parameter.default_labels)):
            if '%s' in self._parameter.default_labels[i]:
                label = (
                    self._parameter.default_labels[i] %
                    self._parameter.default_values[i])
            else:
                label = self._parameter.default_labels[i]

            radio_button = QRadioButton(label)
            self.radio_button_layout.addWidget(radio_button)
            self.default_input_button_group.addButton(radio_button, i)
            if self._parameter.default_value == \
                    self._parameter.default_values[i]:
                radio_button.setChecked(True)

        # Create double spin box for custom value
        self.custom_value = QDoubleSpinBox()
        if self._parameter.default_values[-1]:
            self.custom_value.setValue(self._parameter.default_values[-1])
        has_min = False
        if self._parameter.minimum is not None:
            has_min = True
            self.custom_value.setMinimum(self._parameter.minimum)
        has_max = False
        if self._parameter.maximum is not None:
            has_max = True
            self.custom_value.setMaximum(self._parameter.maximum)
        if has_min and has_max:
            step = (self._parameter.maximum - self._parameter.minimum) / 100.0
            self.custom_value.setSingleStep(step)
        self.radio_button_layout.addWidget(self.custom_value)

        self.toggle_custom_value()

        # Reset the layout
        self.input_layout.setParent(None)
        self.help_layout.setParent(None)

        self.label.setParent(None)
        self.inner_input_layout.setParent(None)

        self.input_layout = QGridLayout()
        self.input_layout.setSpacing(0)

        self.input_layout.addWidget(self.label, 0, 0)
        self.input_layout.addLayout(self.inner_input_layout, 0, 1)
        self.input_layout.addWidget(self.default_label, 1, 0)
        self.input_layout.addLayout(self.radio_button_layout, 1, 1)

        self.main_layout.addLayout(self.input_layout)
        self.main_layout.addLayout(self.help_layout)

        # check every added combobox, it could have been toggled by
        # the existing keyword
        self.toggle_input()

        # Connect
        # noinspection PyUnresolvedReferences
        self.input.currentIndexChanged.connect(self.toggle_input)
        self.default_input_button_group.buttonClicked.connect(
            self.toggle_custom_value)

    def raise_invalid_type_exception(self):
        message = 'Expecting element type of %s' % (
            self._parameter.element_type.__name__)
        err = ValueError(message)
        return err

    def get_parameter(self):
        """Obtain list parameter object from the current widget state.

        :returns: A DefaultSelectParameter from the current state of widget.
        """
        current_index = self.input.currentIndex()
        selected_value = self.input.itemData(current_index, Qt.UserRole)
        if hasattr(selected_value, 'toPyObject'):
#.........这里部分代码省略.........
开发者ID:timlinux,项目名称:inasafe,代码行数:103,代码来源:default_select_parameter_widget.py

示例8: TaskGeneratorDialog

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class TaskGeneratorDialog(QDialog):
    def __init__(self, nbprocessors):
        QDialog.__init__(self)
        self.layout = QVBoxLayout(self)
        self.taskset = None

        # Utilizations:
        vbox_utilizations = QVBoxLayout()
        group = QGroupBox("Task Utilizations:")

        hbox = QHBoxLayout()
        hbox.addWidget(QLabel("Generator:", self))
        self.comboGenerator = QComboBox()
        self.comboGenerator.addItem("RandFixedSum")
        self.comboGenerator.addItem("UUniFast-Discard")
        self.comboGenerator.addItem("Kato's method")
        self.comboGenerator.currentIndexChanged.connect(self.generator_changed)
        hbox.addWidget(self.comboGenerator)
        vbox_utilizations.addLayout(hbox)

        # Load slider + spinner:
        hbox_load = QHBoxLayout()
        sld = _DoubleSlider(QtCore.Qt.Horizontal, self)
        sld.setMinimum(0)
        sld.setMaximum(32)
        self.spin_load = QDoubleSpinBox(self)
        self.spin_load.setMinimum(0)
        self.spin_load.setMaximum(32)
        self.spin_load.setSingleStep(0.1)
        hbox_load.addWidget(QLabel("Total utilization: ", self))
        hbox_load.addWidget(sld)
        hbox_load.addWidget(self.spin_load)
        sld.doubleValueChanged.connect(self.spin_load.setValue)
        self.spin_load.valueChanged.connect(sld.setValue)
        self.spin_load.setValue(nbprocessors / 2.)
        vbox_utilizations.addLayout(hbox_load)

        # Number of periodic tasks:
        self.hbox_tasks = QHBoxLayout()
        self.spin_tasks = QSpinBox(self)
        self.spin_tasks.setMinimum(0)
        self.spin_tasks.setMaximum(999)  # That's arbitrary.
        self.hbox_tasks.addWidget(QLabel("Number of periodic tasks: ", self))
        self.hbox_tasks.addStretch(1)
        self.hbox_tasks.addWidget(self.spin_tasks)
        vbox_utilizations.addLayout(self.hbox_tasks)

        # Number of sporadic tasks:
        self.hbox_sporadic_tasks = QHBoxLayout()
        self.spin_sporadic_tasks = QSpinBox(self)
        self.spin_sporadic_tasks.setMinimum(0)
        self.spin_sporadic_tasks.setMaximum(999)  # That's arbitrary.
        self.hbox_sporadic_tasks.addWidget(
            QLabel("Number of sporadic tasks: ", self))
        self.hbox_sporadic_tasks.addStretch(1)
        self.hbox_sporadic_tasks.addWidget(self.spin_sporadic_tasks)
        vbox_utilizations.addLayout(self.hbox_sporadic_tasks)

        # Min / Max utilizations
        self.hbox_utilizations = QHBoxLayout()
        self.hbox_utilizations.addWidget(QLabel("Min/Max utilizations: ",
                                                self))
        self.interval_utilization = IntervalSpinner(
            self, min_=0, max_=1, step=.01, round_option=False)
        self.hbox_utilizations.addWidget(self.interval_utilization)
        vbox_utilizations.addLayout(self.hbox_utilizations)

        group.setLayout(vbox_utilizations)
        self.layout.addWidget(group)

        # Periods:
        vbox_periods = QVBoxLayout()
        group = QGroupBox("Task Periods:")

        # Log uniform
        self.lunif = QRadioButton("log-uniform distribution between:")
        vbox_periods.addWidget(self.lunif)
        self.lunif.setChecked(True)

        self.lunif_interval = IntervalSpinner(self)
        self.lunif_interval.setEnabled(self.lunif.isChecked())
        self.lunif.toggled.connect(self.lunif_interval.setEnabled)
        vbox_periods.addWidget(self.lunif_interval)

        # Uniform
        self.unif = QRadioButton("uniform distribution between:")
        vbox_periods.addWidget(self.unif)

        self.unif_interval = IntervalSpinner(self)
        self.unif_interval.setEnabled(self.unif.isChecked())
        self.unif.toggled.connect(self.unif_interval.setEnabled)
        vbox_periods.addWidget(self.unif_interval)

        # Discrete
        discrete = QRadioButton("chosen among these (space separated) values:")
        vbox_periods.addWidget(discrete)

        self.periods = QLineEdit(self)
        self.periods.setValidator(QRegExpValidator(
            QRegExp("^\\d*(\.\\d*)?( \\d*(\.\\d*)?)*$")))
#.........这里部分代码省略.........
开发者ID:javipalanca,项目名称:simso,代码行数:103,代码来源:TaskGenerator.py

示例9: Img2GifWidget

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

#.........这里部分代码省略.........
        self.spbLoop = QDoubleSpinBox()
        self.spbLoop = QSpinBox()
        self.spbLoop.setRange(0, 1000)
        self.spbLoop.setSingleStep(1)
        self.spbLoop.setValue(0)
        self.spbLoop.setToolTip(u"0次循环表示永久循环")
        self.spbLoop.setSuffix(u"次")
        self.btnBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        bottomLay = QHBoxLayout()
        bottomLay.addWidget(timeLabel)
        bottomLay.addWidget(self.spbTime)
        bottomLay.addWidget(loopLabel)
        bottomLay.addWidget(self.spbLoop)
        bottomLay.addStretch()
        bottomLay.addWidget(self.btnBox)
        
        mainLay = QVBoxLayout()
        mainLay.addLayout(topLay)
        mainLay.addLayout(midLay)
        mainLay.addLayout(bottomLay)
        self.setLayout(mainLay)

        self.btnAdd.clicked.connect(self.itemAdd)
        self.btnUp.clicked.connect(self.itemUp)
        self.btnDown.clicked.connect(self.itemDown)
        self.btnDel.clicked.connect(self.itemDel)
        self.btnClear.clicked.connect(self.listWidget.clear)
        self.btnBrowser.clicked.connect(self.setGifPath)
        self.btnBox.rejected.connect(self.close)
        self.btnBox.accepted.connect(self.makeGif)

        self.txtGifPath.returnPressed.connect(self.updateGifPath)

    def itemAdd(self):
        fileNames = QFileDialog.getOpenFileNames(None, u"{0} -- {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                                 '.', u'所有文件(*.*);;BMP文件(*.bmp);;PNG文件(*.png);;JPG文件(*.jpg *.jpeg)')
        for fn in fileNames:
            f = QFileInfo(fn)
            if unicode(f.suffix().toLower()) in ['jpg', 'png', 'bmp', 'jpeg']:
                self.listWidget.addItem(fn)

    def itemUp(self):
        row = self.listWidget.currentRow()
        if row <= 0:
            return
        item = self.listWidget.currentItem()
        self.listWidget.takeItem(row)
        self.listWidget.insertItem(row - 1, item)
        self.listWidget.setCurrentRow(row - 1)

    def itemDown(self):
        rows = self.listWidget.count()
        row = self.listWidget.currentRow()
        if (row < 0) or (row == rows - 1):
            return
        item = self.listWidget.currentItem()
        self.listWidget.takeItem(row)
        self.listWidget.insertItem(row + 1, item)
        self.listWidget.setCurrentRow(row + 1)

    def itemDel(self):
        row = self.listWidget.currentRow()
        if row >= 0:
            self.listWidget.takeItem(row)

    def setGifPath(self):
        filename = QFileDialog.getSaveFileName(self, u"{0} -- {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                               ".", "Gif(*.gif)")
        self.txtGifPath.setText(filename)

    def updateGifPath(self):
        fileName = self.txtGifPath.text()
        f = QFileInfo(fileName)
        if f.dir().exists and not f.baseName().isEmpty() and not f.suffix().isEmpty():
            self.txtGifPath.setText(fileName)
            return True
        else:
            QMessageBox.warning(self, u"{0} -- warning".format(Img2GifWidget.AppName),
                                u"要生成的GIF存储路径{0}不是有效的GIF文件".format(unicode(fileName)))
            return False

    def makeGif(self):

        imgs = [unicode(self.listWidget.item(i).text()) for i in range(self.listWidget.count())]
        if len(imgs) <= 1:
            QMessageBox.warning(self, u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                                u"GIF动画文件必须要给定大于一张图片。")
            return
        if not self.updateGifPath():
            return
        durations = self.spbTime.value()
        loops = self.spbLoop.value()
        ok, msg = img2gif.images2gif(imgs, self.txtGifPath.text(), durations=durations, loops=loops)
        if ok:
            QMessageBox.about(self, u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                              u"Succeed!\n{0}".format(msg))
            qApp.processEvents()
        else:
            QMessageBox.about(u"{0} - {1}".format(qApp.applicationName(), Img2GifWidget.AppName),
                              u"sorry! Failed to generate the {0}".format(unicode(self.txtGifPath)))
开发者ID:Liung,项目名称:QAeroData,代码行数:104,代码来源:img2gifWidget.py

示例10: ManualRegistrationWidget

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

#.........这里部分代码省略.........
        self.multiplyDisplay.setVolumeBg(self.imFixed)
        self.multiplyDisplay.render()

    @pyqtSlot()
    def onLoadMoving(self):
        fname = QFileDialog.getOpenFileName(self, 'Load fixed image',
                                            DATA_FOLDER,
                                            filter='TIFF Images (*.tiff *.tif)')
        fname = str(fname)
        if not fname:
            return
        self.imMoving = self.normalizeImage(self.load3DTIFFImage(fname))
        self.statsMoving = ImageStat(self.imMoving)
        self.minMoving, self.maxMoving = self.statsMoving.extrema
        self.overlayDisplay.setVolumeFg(self.imMoving,
                                        self.minMoving, self.maxMoving)
        self.overlayDisplay.setMatrix(self.transformMatrix)
        self.overlayDisplay.render()
        self.buttonMinMaxMoving.setEnabled(True)
        self.multiplyDisplay.setVolumeFg(self.imMoving)
        self.multiplyDisplay.render()

    @pyqtSlot()
    def onClear(self):
        self.spinXAngle.setValue(0.0)
        self.spinXOffset.setValue(0.0)
        self.spinYAngle.setValue(0.0)
        self.spinYOffset.setValue(0.0)
        self.spinZAngle.setValue(0.0)
        self.spinZOffset.setValue(0.0)

    @pyqtSlot()
    def onApply(self):
        xAngle = self.spinXAngle.value() / 180.0 * np.pi
        xOffset = self.spinXOffset.value()
        yAngle = self.spinYAngle.value() / 180.0 * np.pi
        yOffset = self.spinYOffset.value()
        zAngle = self.spinZAngle.value() / 180.0 * np.pi
        zOffset = self.spinZOffset.value()
        # form rotation matrices
        Rx = np.eye(4)
        Rx[1, 1] = np.cos(xAngle)
        Rx[2, 2] = np.cos(xAngle)
        Rx[1, 2] = -np.sin(xAngle)
        Rx[2, 1] = np.sin(xAngle)
        Ry = np.eye(4)
        Ry[0, 0] = np.cos(yAngle)
        Ry[2, 2] = np.cos(yAngle)
        Ry[0, 2] = np.sin(yAngle)
        Ry[2, 0] = -np.sin(yAngle)
        Rz = np.eye(4)
        Rz[0, 0] = np.cos(zAngle)
        Rz[1, 1] = np.cos(zAngle)
        Rz[0, 1] = -np.sin(zAngle)
        Rz[1, 0] = np.sin(zAngle)
        # final transform
        T = np.dot(Rz, np.dot(Ry, Rx))
        T[0, 3] = xOffset
        T[1, 3] = yOffset
        T[2, 3] = zOffset
        self.transformMatrix = np.dot(T, self.transformMatrix)
        self.updateMatrixText()
        self.overlayDisplay.setMatrix(self.transformMatrix)
        self.onClear()

    @pyqtSlot()
开发者ID:lirenzhucn,项目名称:ManualRegistrationTool,代码行数:70,代码来源:ManualRegistrationTool.py

示例11: Widget

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

        groupBox1 = QGroupBox()
        groupBox1.setTitle('Feature weights (model object)')

        self.w1 = QDoubleSpinBox()
        self.w1.setRange(-10.0, 10.0)
        self.w1.setValue(5.0)
        self.w2 = QDoubleSpinBox()
        self.w2.setRange(-10.0, 10.0)
        self.w2.setValue(5.0)
        buttonHelpGroupBox1 = QPushButton('help')
        buttonHelpGroupBox1.setToolTip('Here you enter the neuron\'s weight coefficients for the individual object features.\n' +
                                       'Positive coefficient means approval to the feature, and negative one will indicate that\n' +
                                       'the given feature should be disliked by the neuron.\n\n' +
                                       'Now the only important thing will be the numeric values of the weights and input signals.\n' +
                                       'However, if you want, you can still imagine that the examined objects are flowers - as\n' +
                                       'in the previous program. The w(1) weight will then indicate the fragrance intensity of\n' +
                                       'the flower, and the w(2) weight - its colour intensity.\n\n' +
                                       'You can also think about this as the location of the "model object".')
        buttonHelpGroupBox1.setEnabled(False)

        hBoxLayoutGroupBox1 = QHBoxLayout()
        hBoxLayoutGroupBox1.addWidget(QLabel('w(1) = '))
        hBoxLayoutGroupBox1.addWidget(self.w1)
        hBoxLayoutGroupBox1.addWidget(QLabel('w(2) = '))
        hBoxLayoutGroupBox1.addWidget(self.w2)
        hBoxLayoutGroupBox1.addWidget(buttonHelpGroupBox1)
        groupBox1.setLayout(hBoxLayoutGroupBox1)

        groupBox2 = QGroupBox()
        groupBox2.setTitle('Evaluated object')

        self.x1 = QDoubleSpinBox()
        self.x1.setRange(-10.0, 10.0)
        self.x1.setValue(-5.0)
        self.x2 = QDoubleSpinBox()
        self.x2.setRange(-10.0, 10.0)
        self.x2.setValue(-5.0)
        buttonHelpGroupBox2 = QPushButton('help')
        buttonHelpGroupBox2.setToolTip('Here you can enter the feature values of the evaluated object. As above, you are\n' +
                                       'free to imagine that it is a flower whose fragrance intensity is x(1) and colour intensity\n' +
                                       'is x(2).a')
        buttonHelpGroupBox2.setEnabled(False)

        hBoxLayoutGroupBox2 = QHBoxLayout()
        hBoxLayoutGroupBox2.addWidget(QLabel('x(1) = '))
        hBoxLayoutGroupBox2.addWidget(self.x1)
        hBoxLayoutGroupBox2.addWidget(QLabel('x(2) = '))
        hBoxLayoutGroupBox2.addWidget(self.x2)
        hBoxLayoutGroupBox2.addWidget(buttonHelpGroupBox2)
        groupBox2.setLayout(hBoxLayoutGroupBox2)

        groupBox3 = QGroupBox()
        groupBox3.setTitle('Graph')
        self.colorResponse = QLabel('Evaluated object')
        buttonHelpGroupBox3 = QPushButton('help')
        buttonHelpGroupBox3.setToolTip('On your left, you see a signal graph. The blue point represents the location of the\n' +
                                       'model object. The other point is the location of the evaluated object. Its color, shown\n' +
                                       'on the chart\'s key, corresponds to the neuron\'s attitude towards the evaluated\n' +
                                       'object.\n\n' +
                                       'Click the graph with the right mouse button to set the model object location. The left\n' +
                                       'mouse button sets the evaluated object. You can also perform dragging to move the\n' +
                                       'objects smoothly.')
        buttonHelpGroupBox3.setEnabled(False)

        hBoxLayoutGroupBox3 = QHBoxLayout()
        hBoxLayoutGroupBox3.addWidget(self.colorResponse)
        hBoxLayoutGroupBox3.addWidget(buttonHelpGroupBox3)
        vBoxLayoutGroupBox3 = QVBoxLayout()
        vBoxLayoutGroupBox3.addWidget(QLabel('Key'))
        vBoxLayoutGroupBox3.addWidget(QLabel('Model object'))
        vBoxLayoutGroupBox3.addLayout(hBoxLayoutGroupBox3)
        groupBox3.setLayout(vBoxLayoutGroupBox3)

        self.response = QLabel('0')
        hBoxLayoutResponse = QHBoxLayout()
        hBoxLayoutResponse.addWidget(QLabel('Neuron\'s response: '))
        hBoxLayoutResponse.addWidget(self.response)

        vBoxlayout = QVBoxLayout()
        vBoxlayout.addWidget(QLabel('The neuron that you will be examining will divide the objects you\n' +
                                    'will show it into the ones that it likes and the ones id dislikes.'))
        vBoxlayout.addWidget(groupBox1)
        vBoxlayout.addWidget(groupBox2)
        vBoxlayout.addLayout(hBoxLayoutResponse)
        vBoxlayout.addWidget(groupBox3)

        self.figure = plot.figure()
        self.canvas = FigureCanvas(self.figure)
        self.customePlot()

        hBoxLayout = QHBoxLayout()
        hBoxLayout.addWidget(self.canvas)
        hBoxLayout.addLayout(vBoxlayout)

        self.neuron = Neuron(2)
        self.evaluatedObject()
#.........这里部分代码省略.........
开发者ID:kissofblood,项目名称:neuron,代码行数:103,代码来源:widget.py

示例12: Main

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

#.........这里部分代码省略.........
                    vbox.addWidget(each_widget)

        tw = TransientWidget((self.chooser, self.group1, self.group2,
            QLabel('X-Ayatana-Desktop-Shortcuts'),
            self.ledXAyatanaDesktopShortcuts, QLabel(''),
            self.checkbox1, self.checkbox2, self.button))
        self.dock, self.scrollable = QDockWidget(), QScrollArea()
        self.scrollable.setWidgetResizable(True)
        self.scrollable.setWidget(tw)
        self.dock.setWindowTitle(__doc__)
        self.dock.setStyleSheet('QDockWidget::title{text-align: center;}')
        self.dock.setWidget(self.scrollable)
        ExplorerContainer().addTab(self.dock, "DotDesktop")
        QPushButton(QIcon.fromTheme("help-about"), 'About', self.dock
          ).clicked.connect(lambda: QMessageBox.information(self.dock, __doc__,
          ''.join((__doc__, __version__, __license__, 'by', __author__))))

    def writeFile(self):
        ' write the .desktop file to disk '

        UNITY = ''.join(a for a in iter((
        'OnlyShowIn=', str(self.ledOnlyShowIn.text()), linesep,
        'NotShowIn=', str(self.ledNotShowIn.text()), linesep,
        'X-Ayatana-Desktop-Shortcuts=',
        str(self.ledXAyatanaDesktopShortcuts.text()), linesep)))

        PLASMA = ''.join(a for a in iter((
        'OnlyShowIn=', str(self.ledOnlyShowIn.text()), linesep,
        'NotShowIn=', str(self.ledNotShowIn.text()), linesep,
        'Encoding=', str(self.ledEncoding.currentText()), linesep,
        'ServiceTypes=', str(self.ledServiceType.text()), linesep,
        'X-Plasma-API=', str(self.ledXPlasmaAPI.currentText()), linesep,
        'X-Plasma-MainScript=', str(self.ledXPlasmaMainScript.text()), linesep,
        'X-KDE-PluginInfo-Author=', str(self.ledXKDEPluginInfoAuthor.text()),
        linesep,
        'X-KDE-PluginInfo-Email=', str(self.ledXKDEPluginInfoEmail.text()),
        linesep,
        'X-KDE-PluginInfo-Name=', str(self.ledXKDEPluginInfoName.text()),
        linesep,
        'X-KDE-PluginInfo-Version=', str(self.ledXKDEPluginInfoVersion.text()),
        linesep,
        'X-KDE-PluginInfo-Website=', str(self.ledXKDEPluginInfoWebsite.text()),
        linesep,
        'X-KDE-PluginInfo-Category=',
        str(self.ledXKDEPluginInfoCategory.currentText()), linesep,
        'X-KDE-PluginInfo-Depends=', str(self.ledXKDEPluginInfoDepends.text()),
        linesep,
        'X-KDE-PluginInfo-License=', str(self.ledXKDEPluginInfoLicense.text()),
        linesep,
        'X-KDE-PluginInfo-EnabledByDefault=',
        str(self.ledXKDEPluginInfoEnabledByDefault.currentText()), linesep)))

        BASE = ''.join(a for a in iter((
        '[Desktop Entry]', linesep,
        'Version=', str(self.ledVersion.value()), linesep,
        'Type=', str(self.ledType.text()), linesep,
        'Name=', str(self.ledName.text()), linesep,
        'Comment=', str(self.ledComment.text()), linesep,
        'TryExec=', str(self.ledTryExec.text()), linesep,
        'Exec=', str(self.ledExec.text()), linesep,
        'Icon=', str(self.ledIcon.text()), linesep,
        'MimeType=', str(self.ledMymeType.text()), linesep,
        'Actions=', str(self.ledActions.text()), linesep,
        'Terminal=', str(self.ledTerminal.currentText()), linesep)))

        ACTIONS * len(str(self.ledActions.text()).lower().strip().split(';'))

        fnm = str(QFileDialog.getSaveFileName(self.dock, '', '', "(*.desktop)"))
        with open(fnm, 'w') as f:
            if self.chooser.currentIndex() is 0 and fnm is not '':
                f.write(''.join(a for a in iter((BASE, UNITY, ACTIONS))))
            elif self.chooser.currentIndex() is 1 and fnm is not '':
                f.write(''.join(a for a in iter((BASE, PLASMA))))
            elif fnm is not '':
                f.write(BASE)

        if self.checkbox2.isChecked() and fnm is not '':
            try:
                chmod(fnm, 0775)  # Py2
            except:
                chmod(fnm, 0o775)  # Py3

        if self.checkbox1.isChecked() and fnm is not '':
            self.process.start('ninja-ide ' + fnm)
            if not self.process.waitForStarted():
                print((" ERROR: FAIL: {} failed!".format(fnm)))
                return

    def on_index_changed(self):
        ' enable disable the qgroupbox if needed '
        if self.chooser.currentIndex() is 1:
            self.group2.graphicsEffect().setEnabled(False)
            self.group2.setEnabled(True)
        else:
            self.group2.graphicsEffect().setEnabled(True)
            self.group2.setEnabled(False)
        if self.chooser.currentIndex() is 0:
            self.ledXAyatanaDesktopShortcuts.setEnabled(True)
        else:
            self.ledXAyatanaDesktopShortcuts.setEnabled(False)
开发者ID:imclab,项目名称:dotdesktop,代码行数:104,代码来源:main.py

示例13: IdsIpsFrontend

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
class IdsIpsFrontend(ScrollArea):
    COMPONENT = 'ids_ips'
    LABEL = tr('IDS/IPS')
    REQUIREMENTS = ('ids_ips',)
    ICON = ':/icons/monitoring.png'

    def __init__(self, client, parent):
        ScrollArea.__init__(self)
        if not EDENWALL:
            raise NuConfModuleDisabled("idsips")
        self.client = client
        self.mainwindow = parent
        self._modified = False
        self.error_message = ''
        self._not_modifying = True
        self.config = None

        self.resetConf(no_interface=True)
        self.buildInterface()
        self.updateView()

    @staticmethod
    def get_calls():
        """
        services called by initial multicall
        """
        return (("ids_ips", 'getIdsIpsConfig'),)

    def setModified(self):
        if self._modified or self._not_modifying:
            return

        self._modified = True
        self.emit(SIGNAL('modified'))
        self.mainwindow.setModified(self)

    def mkCheckBox(self, title):
        checkbox = QCheckBox(title)
        self.connect(checkbox, SIGNAL('stateChanged(int)'), self.setModified)
        return checkbox

    def buildInterface(self):
        frame = QFrame()
        grid = QGridLayout(frame)
        self.setWidget(frame)
        self.setWidgetResizable(True)

        title = u'<h1>%s</h1>' % self.tr('Intrusion detection/prevention system')
        grid.addWidget(QLabel(title), 0, 0, 1, 2) #fromrow, fromcol, rowspan, colspan

        self.activation_box = self.mkCheckBox(tr('Enable IDS-IPS'))
        self.connect(self.activation_box, SIGNAL('stateChanged(int)'), self.config.setEnabled)
        grid.addWidget(self.activation_box, 1, 0)

        alerts, sub_form = mkGroupBox(tr('Alerts (IDS)'))

        self.alert_threshold = QDoubleSpinBox()
        sub_form.addRow(tr('Threshold for rule selection'), self.alert_threshold)
        self.connect(self.alert_threshold, SIGNAL('valueChanged(double)'),
                     self.setAlertThreshold)
        self.connect(self.alert_threshold, SIGNAL('valueChanged(double)'), self.setModified)
        self.threshold_message = QLabel()
        self.threshold_message.setWordWrap(True)
        sub_form.addRow(self.threshold_message)

        self.alert_count_message = QLabel()
        self.alert_count_message.setWordWrap(True)
        sub_form.addRow(self.alert_count_message)

        self.threshold_range = MessageArea()
        sub_form.addRow(self.threshold_range)

        grid.addWidget(alerts, 2, 0)

        blocking, sub_form = mkGroupBox(tr('Blocking (IPS)'))

        self.block = self.mkCheckBox(tr('Block'))
        self.connect(self.block, SIGNAL('stateChanged(int)'), self.config.setBlockingEnabled)
        sub_form.addRow(self.block)
        self.drop_threshold = QDoubleSpinBox()
        sub_form.addRow(tr('Rule selection threshold for blocking'), self.drop_threshold)

        self.drop_count_message = QLabel()
        self.drop_count_message.setWordWrap(True)
        sub_form.addRow(self.drop_count_message)

        self.connect(self.drop_threshold, SIGNAL('valueChanged(double)'), self.setDropThreshold)
        self.connect(self.drop_threshold, SIGNAL('valueChanged(double)'), self.setModified)
        self.connect(
            self.block,
            SIGNAL('stateChanged(int)'),
            self.drop_threshold.setEnabled
        )

        grid.addWidget(blocking, 2, 1)

        antivirus, sub_form = mkGroupBox(tr('Antivirus'))

        self.antivirus_toggle = self.mkCheckBox(tr('Enable antivirus '))
        self.connect(self.antivirus_toggle, SIGNAL('stateChanged(int)'), self.config.setAntivirusEnabled)
#.........这里部分代码省略.........
开发者ID:maximerobin,项目名称:Ufwi,代码行数:103,代码来源:ids_ips.py

示例14: value

# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import value [as 别名]
 def value(self):
     return QDoubleSpinBox.value(self)
开发者ID:flupke,项目名称:pyflu,代码行数:4,代码来源:duck_widgets.py

示例15: GeoLocationWidget

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

    """GeoLocationWidget(QWidget)

    Provides a custom geographical location widget.
    """

    __pyqtSignals__ = ("latitudeChanged(double)", "longitudeChanged(double)", "elevationChanged(double)")

    def __init__(self, parent = None):
        super().__init__(parent)

        latitudeLabel = QLabel(self.tr("Latitude:"))
        self.latitudeSpinBox = QDoubleSpinBox()
        self.latitudeSpinBox.setRange(-90.0, 90.0)
        self.latitudeSpinBox.setDecimals(5)
        self.latitudeSpinBox.setSuffix(" degrees")
        self.latitudeSpinBox.setToolTip("How far north or sourth you are from the equator. Must be between -90 and 90.")

        longitudeLabel = QLabel(self.tr("Longitude:"))
        self.longitudeSpinBox = QDoubleSpinBox()
        self.longitudeSpinBox.setRange(-180.0, 180.0)
        self.longitudeSpinBox.setDecimals(5)
        self.longitudeSpinBox.setSuffix(" degrees")
        self.longitudeSpinBox.setToolTip("How far west or east you are from the meridian. Must be between -180 and 180.")

        elevationLabel = QLabel(self.tr("Elevation"))
        self.elevationSpinBox = QDoubleSpinBox()
        self.elevationSpinBox.setRange(-418.0, 8850.0)
        self.elevationSpinBox.setDecimals(5)
        self.elevationSpinBox.setSuffix(" m")
        self.elevationSpinBox.setToolTip("The distance from sea level in meters. Must be between -418 and 8850.")

        self.connect(self.latitudeSpinBox, SIGNAL("valueChanged(double)"),
                     self, SIGNAL("latitudeChanged(double)"))
        self.connect(self.longitudeSpinBox, SIGNAL("valueChanged(double)"),
                     self, SIGNAL("longitudeChanged(double)"))
        self.connect(self.elevationSpinBox, SIGNAL("valueChanged(double)"),
                     self, SIGNAL("elevationChanged(double)"))

        layout = QGridLayout(self)
        layout.addWidget(latitudeLabel, 0, 0)
        layout.addWidget(self.latitudeSpinBox, 1, 0)
        layout.addWidget(longitudeLabel, 0, 1)
        layout.addWidget(self.longitudeSpinBox, 1, 1)
        layout.addWidget(elevationLabel, 0, 2)
        layout.addWidget(self.elevationSpinBox, 1, 2)

    # The latitude property is implemented with the latitude() and setLatitude()
    # methods, and contains the latitude of the user.

    def latitude(self):
        return self.latitudeSpinBox.value()

    @pyqtSignature("setLatitude(double)")
    def setLatitude(self, latitude):
        if latitude != self.latitudeSpinBox.value():
            self.latitudeSpinBox.setValue(latitude)
            self.emit(SIGNAL("latitudeChanged(double)"), latitude)

    latitude = pyqtProperty("double", latitude, setLatitude)

    # The longitude property is implemented with the longitude() and setlongitude()
    # methods, and contains the longitude of the user.

    def longitude(self):
        return self.longitudeSpinBox.value()

    @pyqtSignature("setLongitude(double)")
    def setLongitude(self, longitude):
        if longitude != self.longitudeSpinBox.value():
            self.longitudeSpinBox.setValue(longitude)
            self.emit(SIGNAL("longitudeChanged(double)"), longitude)

    longitude = pyqtProperty("double", longitude, setLongitude)

    def elevation(self):
        return self.elevationSpinBox.value()

    @pyqtSignature("setElevation(double)")
    def setElevation(self, elevation):
        if elevation != self.elevationSpinBox.value():
            self.elevationSpinBox.setValue(elevation)
            self.emit(SIGNAL("elevationChanged(double)"), elevation)

    elevation = pyqtProperty("double", elevation, setElevation)
开发者ID:B-Rich,项目名称:ChronosLNX,代码行数:88,代码来源:geolocationwidget.py


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