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


Python QDoubleSpinBox.setStyleSheet方法代码示例

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


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

示例1: TimeInputLine

# 需要导入模块: from PyQt5.Qt import QDoubleSpinBox [as 别名]
# 或者: from PyQt5.Qt.QDoubleSpinBox import setStyleSheet [as 别名]
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,代码行数:88,代码来源:Components.py


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