当前位置: 首页 pyqt5快速开发与实战_PyQt5项目实战案例 通过类型提升和属性设置完善界面样式
add-vip

通过类型提升和属性设置完善界面样式

通过类型提升和属性设置完善界面样式


from PyQt5.Qt import *


class BtnSun(QPushButton):
    def __init__(self, parent=None, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)

        self.setStyleSheet(
            '''
            QPushButton[bg='gray']{
                color:white;
                background-color:rgb(88, 88, 88)
            }
            QPushButton[bg='gray']:hover{
                background-color:rgb(150, 150, 150)
            }
            
            
            QPushButton[bg='orange']{
                color:white;
                background-color:rgb(200, 120, 0)
            }
            QPushButton[bg='orange']:hover{
                background-color:rgb(250, 200, 0)
            }
            
            
            QPushButton[bg='lightgray']{
                color:black;
                background-color:rgb(200, 200, 200)
            }
            QPushButton[bg='lightgray']:hover{
                background-color:rgb(230, 230, 230)
            }
            
            QPushButton[bg]{
                border-radius:%dpx;
            }

            ''' % (min(self.width(), self.height())/2)
        )



相关文章