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


Python Qt.QDoubleSpinBox类代码示例

本文整理汇总了Python中PyQt5.Qt.QDoubleSpinBox的典型用法代码示例。如果您正苦于以下问题:Python QDoubleSpinBox类的具体用法?Python QDoubleSpinBox怎么用?Python QDoubleSpinBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, name, layout):
     QDoubleSpinBox.__init__(self)
     self.setRange(0, 10000)
     self.setDecimals(1)
     opt = options[name]
     self.valueChanged.connect(self.changed_signal.emit)
     init_opt(self, opt, layout)
开发者ID:bwhitenb5e,项目名称:calibre,代码行数:7,代码来源:server.py

示例2: setup_ui

 def setup_ui(self, parent):
     self.make_widgets(parent, EditWithComplete)
     values = self.all_values = list(self.db.all_custom(num=self.col_id))
     values.sort(key=sort_key)
     self.main_widget.setSizeAdjustPolicy(self.main_widget.AdjustToMinimumContentsLengthWithIcon)
     self.main_widget.setMinimumContentsLength(25)
     self.widgets.append(QLabel('', parent))
     w = QWidget(parent)
     layout = QHBoxLayout(w)
     layout.setContentsMargins(0, 0, 0, 0)
     self.remove_series = QCheckBox(parent)
     self.remove_series.setText(_('Clear series'))
     layout.addWidget(self.remove_series)
     self.idx_widget = QCheckBox(parent)
     self.idx_widget.setText(_('Automatically number books'))
     self.idx_widget.setToolTip('<p>' + _(
         'If not checked, the series number for the books will be set to 1. '
         'If checked, selected books will be automatically numbered, '
         'in the order you selected them. So if you selected '
         'Book A and then Book B, Book A will have series number 1 '
         'and Book B series number 2.') + '</p>')
     layout.addWidget(self.idx_widget)
     self.force_number = QCheckBox(parent)
     self.force_number.setText(_('Force numbers to start with '))
     self.force_number.setToolTip('<p>' + _(
         'Series will normally be renumbered from the highest '
         'number in the database for that series. Checking this '
         'box will tell calibre to start numbering from the value '
         'in the box') + '</p>')
     layout.addWidget(self.force_number)
     self.series_start_number = QDoubleSpinBox(parent)
     self.series_start_number.setMinimum(0.0)
     self.series_start_number.setMaximum(9999999.0)
     self.series_start_number.setProperty("value", 1.0)
     layout.addWidget(self.series_start_number)
     self.series_increment = QDoubleSpinBox(parent)
     self.series_increment.setMinimum(0.00)
     self.series_increment.setMaximum(99999.0)
     self.series_increment.setProperty("value", 1.0)
     self.series_increment.setToolTip('<p>' + _(
         'The amount by which to increment the series number '
         'for successive books. Only applicable when using '
         'force series numbers.') + '</p>')
     self.series_increment.setPrefix('+')
     layout.addWidget(self.series_increment)
     layout.addItem(QSpacerItem(20, 10, QSizePolicy.Expanding, QSizePolicy.Minimum))
     self.widgets.append(w)
     self.idx_widget.stateChanged.connect(self.a_c_checkbox_changed)
     self.force_number.stateChanged.connect(self.a_c_checkbox_changed)
     self.series_start_number.valueChanged.connect(self.a_c_checkbox_changed)
     self.series_increment.valueChanged.connect(self.a_c_checkbox_changed)
     self.remove_series.stateChanged.connect(self.a_c_checkbox_changed)
     self.main_widget
     self.ignore_change_signals = False
开发者ID:aimylios,项目名称:calibre,代码行数:54,代码来源:custom_column_widgets.py

示例3: setup_ui

    def setup_ui(self):
        self.l = l = QFormLayout(self)
        l.addRow(QLabel(_('Print %s to a PDF file') % elided_text(self.book_title)))
        self.h = h = QHBoxLayout()
        self.file_name = f = QLineEdit(self)
        val = dynamic.get(self.OUTPUT_NAME, None)
        if not val:
            val = expanduser('~')
        else:
            val = os.path.dirname(val)
        f.setText(os.path.abspath(os.path.join(val, self.default_file_name)))
        self.browse_button = b = QToolButton(self)
        b.setIcon(QIcon(I('document_open.png'))), b.setToolTip(_('Choose location for PDF file'))
        b.clicked.connect(self.choose_file)
        h.addWidget(f), h.addWidget(b)
        f.setMinimumWidth(350)
        w = QLabel(_('&File:'))
        l.addRow(w, h), w.setBuddy(f)

        self.paper_size = ps = QComboBox(self)
        ps.addItems([a.upper() for a in sorted(self.paper_size_map, key=numeric_sort_key)])
        previous_size = vprefs.get('print-to-pdf-page-size', None)
        if previous_size not in self.paper_size_map:
            previous_size = (QPrinter().pageLayout().pageSize().name() or '').lower()
        if previous_size not in self.paper_size_map:
            previous_size = 'a4'
        ps.setCurrentIndex(ps.findText(previous_size.upper()))
        l.addRow(_('Paper &size:'), ps)
        tmap = {
                'left':_('&Left margin:'),
                'top':_('&Top margin:'),
                'right':_('&Right margin:'),
                'bottom':_('&Bottom margin:'),
        }
        for edge in 'left top right bottom'.split():
            m = QDoubleSpinBox(self)
            m.setSuffix(' ' + _('inches'))
            m.setMinimum(0), m.setMaximum(3), m.setSingleStep(0.1)
            val = vprefs.get('print-to-pdf-%s-margin' % edge, 1)
            m.setValue(val)
            setattr(self, '%s_margin' % edge, m)
            l.addRow(tmap[edge], m)
        self.pnum = pnum = QCheckBox(_('Add page &number to printed pages'), self)
        pnum.setChecked(vprefs.get('print-to-pdf-page-numbers', True))
        l.addRow(pnum)

        self.show_file = sf = QCheckBox(_('Open PDF file after printing'), self)
        sf.setChecked(vprefs.get('print-to-pdf-show-file', True))
        l.addRow(sf)

        l.addRow(self.bb)
开发者ID:Aliminator666,项目名称:calibre,代码行数:51,代码来源:printing.py

示例4: setupUi

 def setupUi(self, *a):
     self.l = l = QFormLayout(self)
     self.opt_docx_page_size = QComboBox(self)
     l.addRow(_('Paper si&ze:'), self.opt_docx_page_size)
     self.opt_docx_custom_page_size = w = QLineEdit(self)
     w.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
     l.addRow(_('&Custom size:'), w)
     for i, text in enumerate((_('Page &left margin'), _('Page &top margin'), _('Page &right margin'), _('Page &bottom margin'))):
         m = 'left top right bottom'.split()[i]
         w = QDoubleSpinBox(self)
         w.setRange(-100, 500), w.setSuffix(' pt'), w.setDecimals(1)
         setattr(self, 'opt_docx_page_margin_' + m, w)
         l.addRow(text + ':', w)
     self.opt_docx_no_toc = QCheckBox(_('Do not insert the &Table of Contents as a page at the start of the document'))
     l.addRow(self.opt_docx_no_toc)
     self.opt_docx_no_cover = QCheckBox(_('Do not insert &cover as image at start of document'))
     l.addRow(self.opt_docx_no_cover)
开发者ID:bwhitenb5e,项目名称:calibre,代码行数:17,代码来源:docx_output.py

示例5: initUI

 def initUI(self):
     self.resize(TimeInputLine.WIDTH + TimeInputLine.FRAME_MARGIN*2, TimeInputLine.HEIGHT + TimeInputLine.FRAME_MARGIN*2)
     self.setFrameStyle(QFrame.StyledPanel)
     self.setLineWidth(TimeInputLine.FRAME_WIDTH)
     
     component_stylesheet = """
                             .QPushButton {
                                 font-weight: bold;
                                 font-size: 13px;
                                 background-color:#E0E0E0;
                             }
                             .QPushButton:pressed {
                                 background-color:#CCCCCC;
                             }
                             .QDoubleSpinBox {
                                 font-weight: bold;
                                 font-size: 23px;
                             }
                             .QLabel {
                                 font-weight: bold;
                                 font-size: 23px;
                             }
                         """
     
     self.label = QLabel("", self)
     self.label.resize(TimeInputLine.LABEL_SIZE_X, TimeInputLine.HEIGHT)
     self.label.move(TimeInputLine.FRAME_MARGIN, TimeInputLine.FRAME_MARGIN)
     self.label.setStyleSheet(component_stylesheet)
     self.label.setAlignment(Qt.AlignCenter)
     self.label.show()       
     
     self.spinbox = QDoubleSpinBox(self)
     self.spinbox.setRange(TimeInputLine.MIN_VALUE, TimeInputLine.MAX_VALUE)
     self.spinbox.setValue(TimeInputLine.STEP)
     self.spinbox.setSingleStep(TimeInputLine.STEP)
     self.spinbox.setDecimals(TimeInputLine.DECIMAL_COUNT)
     self.spinbox.resize(TimeInputLine.INPUT_SIZE_X, TimeInputLine.HEIGHT)
     self.spinbox.move(TimeInputLine.LABEL_SIZE_X + TimeInputLine.FRAME_MARGIN, TimeInputLine.FRAME_MARGIN)
     self.spinbox.setStyleSheet(component_stylesheet)
     self.spinbox.show()
     
     self.enter = QPushButton("", self)
     self.enter.setIcon(assets.enter)
     self.enter.setIconSize(QSize(TimeInputLine.ICON_SIZE, TimeInputLine.ICON_SIZE))
     self.enter.resize(TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.HEIGHT)
     self.enter.move(TimeInputLine.BUTTON_BLOCK_X, TimeInputLine.FRAME_MARGIN)  
     self.enter.setStyleSheet(component_stylesheet)
     self.enter.show()
     
     self.cancel = QPushButton("", self)
     self.cancel.setIcon(assets.exit)
     self.cancel.setIconSize(QSize(TimeInputLine.ICON_SIZE, TimeInputLine.ICON_SIZE))
     self.cancel.resize(TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.HEIGHT)
     self.cancel.move(TimeInputLine.BUTTON_BLOCK_X + TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.FRAME_MARGIN)     
     self.cancel.setStyleSheet(component_stylesheet) 
     self.cancel.show()
开发者ID:artemmoskalev,项目名称:stickman_animator,代码行数:56,代码来源:Components.py

示例6: __init__

    def __init__(self, parent=None):
        Base.__init__(self, parent)
        self.l1 = QLabel(_('&Download every:'))
        self.interval = QDoubleSpinBox(self)
        self.interval.setMinimum(0.04)
        self.interval.setSpecialValueText(_('every hour'))
        self.interval.setMaximum(1000.0)
        self.interval.setValue(31.0)
        self.interval.setSuffix(' ' + _('days'))
        self.interval.setSingleStep(1.0)
        self.interval.setDecimals(2)
        self.l1.setBuddy(self.interval)
        self.l2 = QLabel(_('Note: You can set intervals of less than a day,'
            ' by typing the value manually.'))
        self.l2.setWordWrap(True)

        self.l.addWidget(self.l1, 0, 0, 1, 1)
        self.l.addWidget(self.interval, 0, 1, 1, 1)
        self.l.addWidget(self.l2, 1, 0, 1, -1)
开发者ID:AtulKumar2,项目名称:calibre,代码行数:19,代码来源:scheduler.py

示例7: __init__

    def __init__(self, title, parent = None):
        super(SliderWidget, self).__init__(parent, Qt.FramelessWindowHint)
        self._mousePressed = False
        self._orgPos = QPoint(0, 0)
        self.setObjectName('SliderWidget')
        self.resize(500, 150)

        #
        self.stylize()

        # main layout
        labelTitle = QLabel(title, self)
        buttonClose = JCloseButton(self)
        buttonClose.setObjectName('buttonClose')
        buttonClose.setToolTip('关闭')

        horiLayoutTitle = QHBoxLayout()
        horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
        horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
        horiLayoutTitle.addStretch()
        horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)

        self.doubleSpinBox = QDoubleSpinBox(self)
        self.doubleSpinBox.setObjectName('doubleSpinBox')
        self.doubleSpinBox.setMinimumWidth(200)
        self.doubleSpinBox.setRange(0, 6000)
        self.doubleSpinBox.setDecimals(2)
        self.doubleSpinBox.setSingleStep(0.01)

        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setObjectName('slider')
        self.slider.setRange(self.doubleSpinBox.minimum(),
                             self.doubleSpinBox.maximum())
        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTitle)
        vertLayoutMain.addWidget(self.doubleSpinBox, 0, Qt.AlignHCenter)
        vertLayoutMain.addSpacing(5)
        vertLayoutMain.addWidget(self.slider)

        self.slider.rangeChanged.connect(self.doubleSpinBox.setRange)
        self.doubleSpinBox.valueChanged.connect(self.doubleSpinBoxValueChanged)
        self.slider.valueChanged.connect(self.setValue)
        buttonClose.clicked.connect(self.close)
开发者ID:iclosure,项目名称:carmonitor,代码行数:43,代码来源:slider_widget.py

示例8: BulkSeries

class BulkSeries(BulkBase):

    def setup_ui(self, parent):
        self.make_widgets(parent, EditWithComplete)
        values = self.all_values = list(self.db.all_custom(num=self.col_id))
        values.sort(key=sort_key)
        self.main_widget.setSizeAdjustPolicy(self.main_widget.AdjustToMinimumContentsLengthWithIcon)
        self.main_widget.setMinimumContentsLength(25)
        self.widgets.append(QLabel('', parent))
        w = QWidget(parent)
        layout = QHBoxLayout(w)
        layout.setContentsMargins(0, 0, 0, 0)
        self.remove_series = QCheckBox(parent)
        self.remove_series.setText(_('Clear series'))
        layout.addWidget(self.remove_series)
        self.idx_widget = QCheckBox(parent)
        self.idx_widget.setText(_('Automatically number books'))
        self.idx_widget.setToolTip('<p>' + _(
            'If not checked, the series number for the books will be set to 1. '
            'If checked, selected books will be automatically numbered, '
            'in the order you selected them. So if you selected '
            'Book A and then Book B, Book A will have series number 1 '
            'and Book B series number 2.') + '</p>')
        layout.addWidget(self.idx_widget)
        self.force_number = QCheckBox(parent)
        self.force_number.setText(_('Force numbers to start with '))
        self.force_number.setToolTip('<p>' + _(
            'Series will normally be renumbered from the highest '
            'number in the database for that series. Checking this '
            'box will tell calibre to start numbering from the value '
            'in the box') + '</p>')
        layout.addWidget(self.force_number)
        self.series_start_number = QDoubleSpinBox(parent)
        self.series_start_number.setMinimum(0.0)
        self.series_start_number.setMaximum(9999999.0)
        self.series_start_number.setProperty("value", 1.0)
        layout.addWidget(self.series_start_number)
        self.series_increment = QDoubleSpinBox(parent)
        self.series_increment.setMinimum(0.00)
        self.series_increment.setMaximum(99999.0)
        self.series_increment.setProperty("value", 1.0)
        self.series_increment.setToolTip('<p>' + _(
            'The amount by which to increment the series number '
            'for successive books. Only applicable when using '
            'force series numbers.') + '</p>')
        self.series_increment.setPrefix('+')
        layout.addWidget(self.series_increment)
        layout.addItem(QSpacerItem(20, 10, QSizePolicy.Expanding, QSizePolicy.Minimum))
        self.widgets.append(w)
        self.idx_widget.stateChanged.connect(self.a_c_checkbox_changed)
        self.force_number.stateChanged.connect(self.a_c_checkbox_changed)
        self.series_start_number.valueChanged.connect(self.a_c_checkbox_changed)
        self.series_increment.valueChanged.connect(self.a_c_checkbox_changed)
        self.remove_series.stateChanged.connect(self.a_c_checkbox_changed)
        self.main_widget
        self.ignore_change_signals = False

    def a_c_checkbox_changed(self):
        def disable_numbering_checkboxes(idx_widget_enable):
            if idx_widget_enable:
                self.idx_widget.setEnabled(True)
            else:
                self.idx_widget.setChecked(False)
                self.idx_widget.setEnabled(False)
            self.force_number.setChecked(False)
            self.force_number.setEnabled(False)
            self.series_start_number.setEnabled(False)
            self.series_increment.setEnabled(False)

        if self.ignore_change_signals:
            return
        self.ignore_change_signals = True
        apply_changes = False
        if self.remove_series.isChecked():
            self.main_widget.setText('')
            self.main_widget.setEnabled(False)
            disable_numbering_checkboxes(idx_widget_enable=False)
            apply_changes = True
        elif self.main_widget.text():
            self.remove_series.setEnabled(False)
            self.idx_widget.setEnabled(True)
            apply_changes = True
        else:  # no text, no clear. Basically reinitialize
            self.main_widget.setEnabled(True)
            self.remove_series.setEnabled(True)
            disable_numbering_checkboxes(idx_widget_enable=False)
            apply_changes = False

        self.force_number.setEnabled(self.idx_widget.isChecked())
        self.series_start_number.setEnabled(self.force_number.isChecked())
        self.series_increment.setEnabled(self.force_number.isChecked())

        self.ignore_change_signals = False
        self.a_c_checkbox.setChecked(apply_changes)

    def initialize(self, book_id):
        self.idx_widget.setChecked(False)
        self.main_widget.set_separator(None)
        self.main_widget.update_items_cache(self.all_values)
        self.main_widget.setEditText('')
#.........这里部分代码省略.........
开发者ID:aimylios,项目名称:calibre,代码行数:101,代码来源:custom_column_widgets.py

示例9: __init__

 def __init__(self, *args, **kwargs):
     QDoubleSpinBox.__init__(self, *args, **kwargs)
     self.tt = _('Position in book')
     self.setToolTip(self.tt)
开发者ID:Cykooz,项目名称:calibre,代码行数:4,代码来源:ui.py

示例10: EveryXDays

class EveryXDays(Base):

    HELP = _('''\
                Download this periodical every x days. For example, if you
                choose 30 days, the periodical will be downloaded every 30
                days. Note that you can set periods of less than a day, like
                0.1 days to download a periodical more than once a day.
            ''')

    def __init__(self, parent=None):
        Base.__init__(self, parent)
        self.l1 = QLabel(_('&Download every:'))
        self.interval = QDoubleSpinBox(self)
        self.interval.setMinimum(0.04)
        self.interval.setSpecialValueText(_('every hour'))
        self.interval.setMaximum(1000.0)
        self.interval.setValue(31.0)
        self.interval.setSuffix(' ' + _('days'))
        self.interval.setSingleStep(1.0)
        self.interval.setDecimals(2)
        self.l1.setBuddy(self.interval)
        self.l2 = QLabel(_('Note: You can set intervals of less than a day,'
            ' by typing the value manually.'))
        self.l2.setWordWrap(True)

        self.l.addWidget(self.l1, 0, 0, 1, 1)
        self.l.addWidget(self.interval, 0, 1, 1, 1)
        self.l.addWidget(self.l2, 1, 0, 1, -1)

    def initialize(self, typ=None, val=None):
        if val is None:
            val = 31.0
        self.interval.setValue(val)

    @property
    def schedule(self):
        schedule = self.interval.value()
        return 'interval', schedule
开发者ID:AtulKumar2,项目名称:calibre,代码行数:38,代码来源:scheduler.py

示例11: TimeInputLine

class TimeInputLine(QFrame):
    
    WIDTH = 396
    HEIGHT = 43
    
    FRAME_WIDTH = 1
    FRAME_MARGIN = 2
    
    ICON_SIZE = 35
    ICON_BUTTON_WIDTH = 60    
    
    LABEL_SIZE_X = 174
    INPUT_SIZE_X = 100
    BUTTON_BLOCK_X = 278
    
    STEP = 0.5
    MIN_VALUE = 0.1
    MAX_VALUE = 10
    DECIMAL_COUNT = 1
    
    def __init__(self, parent):
        super().__init__(parent)
        self.initUI()       
    
    def initUI(self):
        self.resize(TimeInputLine.WIDTH + TimeInputLine.FRAME_MARGIN*2, TimeInputLine.HEIGHT + TimeInputLine.FRAME_MARGIN*2)
        self.setFrameStyle(QFrame.StyledPanel)
        self.setLineWidth(TimeInputLine.FRAME_WIDTH)
        
        component_stylesheet = """
                                .QPushButton {
                                    font-weight: bold;
                                    font-size: 13px;
                                    background-color:#E0E0E0;
                                }
                                .QPushButton:pressed {
                                    background-color:#CCCCCC;
                                }
                                .QDoubleSpinBox {
                                    font-weight: bold;
                                    font-size: 23px;
                                }
                                .QLabel {
                                    font-weight: bold;
                                    font-size: 23px;
                                }
                            """
        
        self.label = QLabel("", self)
        self.label.resize(TimeInputLine.LABEL_SIZE_X, TimeInputLine.HEIGHT)
        self.label.move(TimeInputLine.FRAME_MARGIN, TimeInputLine.FRAME_MARGIN)
        self.label.setStyleSheet(component_stylesheet)
        self.label.setAlignment(Qt.AlignCenter)
        self.label.show()       
        
        self.spinbox = QDoubleSpinBox(self)
        self.spinbox.setRange(TimeInputLine.MIN_VALUE, TimeInputLine.MAX_VALUE)
        self.spinbox.setValue(TimeInputLine.STEP)
        self.spinbox.setSingleStep(TimeInputLine.STEP)
        self.spinbox.setDecimals(TimeInputLine.DECIMAL_COUNT)
        self.spinbox.resize(TimeInputLine.INPUT_SIZE_X, TimeInputLine.HEIGHT)
        self.spinbox.move(TimeInputLine.LABEL_SIZE_X + TimeInputLine.FRAME_MARGIN, TimeInputLine.FRAME_MARGIN)
        self.spinbox.setStyleSheet(component_stylesheet)
        self.spinbox.show()
        
        self.enter = QPushButton("", self)
        self.enter.setIcon(assets.enter)
        self.enter.setIconSize(QSize(TimeInputLine.ICON_SIZE, TimeInputLine.ICON_SIZE))
        self.enter.resize(TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.HEIGHT)
        self.enter.move(TimeInputLine.BUTTON_BLOCK_X, TimeInputLine.FRAME_MARGIN)  
        self.enter.setStyleSheet(component_stylesheet)
        self.enter.show()
        
        self.cancel = QPushButton("", self)
        self.cancel.setIcon(assets.exit)
        self.cancel.setIconSize(QSize(TimeInputLine.ICON_SIZE, TimeInputLine.ICON_SIZE))
        self.cancel.resize(TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.HEIGHT)
        self.cancel.move(TimeInputLine.BUTTON_BLOCK_X + TimeInputLine.ICON_BUTTON_WIDTH, TimeInputLine.FRAME_MARGIN)     
        self.cancel.setStyleSheet(component_stylesheet) 
        self.cancel.show()
    
    """ listeners which control what happens on accept and on cancel button presses """
    def addAcceptListener(self, onAcceptListener):
        self.enter.clicked.connect(onAcceptListener)
    def addCancelListener(self, onCancelListener):
        self.cancel.clicked.connect(onCancelListener)   
开发者ID:artemmoskalev,项目名称:stickman_animator,代码行数:86,代码来源:Components.py

示例12: margin

 def margin(which):
     w = QDoubleSpinBox(self)
     w.setRange(-100, 500), w.setSuffix(' pt'), w.setDecimals(1)
     setattr(self, 'opt_pdf_page_margin_' + which, w)
     return w
开发者ID:aimylios,项目名称:calibre,代码行数:5,代码来源:pdf_output.py

示例13: keyPressEvent

 def keyPressEvent(self, ev):
     if ev.key() == Qt.Key_Space:
         self.setValue(-1000000.0)
     else:
         return QDoubleSpinBox.keyPressEvent(self, ev)
开发者ID:GaryMMugford,项目名称:calibre,代码行数:5,代码来源:delegates.py

示例14: SliderWidget

class SliderWidget(QDialog):
    '''
    class SliderWidget
    '''
    valueChanged = QtCore.pyqtSignal(float)
    def __init__(self, title, parent = None):
        super(SliderWidget, self).__init__(parent, Qt.FramelessWindowHint)
        self._mousePressed = False
        self._orgPos = QPoint(0, 0)
        self.setObjectName('SliderWidget')
        self.resize(500, 150)

        #
        self.stylize()

        # main layout
        labelTitle = QLabel(title, self)
        buttonClose = JCloseButton(self)
        buttonClose.setObjectName('buttonClose')
        buttonClose.setToolTip('关闭')

        horiLayoutTitle = QHBoxLayout()
        horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
        horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
        horiLayoutTitle.addStretch()
        horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)

        self.doubleSpinBox = QDoubleSpinBox(self)
        self.doubleSpinBox.setObjectName('doubleSpinBox')
        self.doubleSpinBox.setMinimumWidth(200)
        self.doubleSpinBox.setRange(0, 6000)
        self.doubleSpinBox.setDecimals(2)
        self.doubleSpinBox.setSingleStep(0.01)

        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setObjectName('slider')
        self.slider.setRange(self.doubleSpinBox.minimum(),
                             self.doubleSpinBox.maximum())
        vertLayoutMain = QVBoxLayout(self)
        vertLayoutMain.addLayout(horiLayoutTitle)
        vertLayoutMain.addWidget(self.doubleSpinBox, 0, Qt.AlignHCenter)
        vertLayoutMain.addSpacing(5)
        vertLayoutMain.addWidget(self.slider)

        self.slider.rangeChanged.connect(self.doubleSpinBox.setRange)
        self.doubleSpinBox.valueChanged.connect(self.doubleSpinBoxValueChanged)
        self.slider.valueChanged.connect(self.setValue)
        buttonClose.clicked.connect(self.close)

    def setRange(self, minValue, maxValue):
        self.slider.setRange(minValue, maxValue)

    def setDecimals(self, prec):
        self.doubleSpinBox.setDecimals(prec)

    def setSingleStep(self, value):
        self.doubleSpinBox.setSingleStep(value)

    def setPrefix(self, prefix):
        self.doubleSpinBox.setPrefix(prefix)

    def setSuffix(self, suffix):
        self.doubleSpinBox.setSuffix(suffix)

    def doubleSpinBoxValueChanged(self, value):
        self.slider.setValue(value)
        self.valueChanged.emit(value)

    @QtCore.pyqtSlot(float)
    def setValue(self, value):
        self.doubleSpinBox.setValue(value)

    @QtCore.pyqtSlot()
    def stylize(self):
        styles.stylize(self)

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self._mousePressed = True
            self._orgPos = event.pos()
            self.setCursor(Qt.ClosedHandCursor)

    def mouseMoveEvent(self, event):
        if self._mousePressed:
            curPos = event.pos()
            curGeom = self.geometry()
            self.move(curGeom.topLeft() + curPos - self._orgPos)

    def mouseReleaseEvent(self, event):
        self._mousePressed = False
        self.setCursor(Qt.ArrowCursor)
开发者ID:iclosure,项目名称:carmonitor,代码行数:91,代码来源:slider_widget.py


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