forked from Fluorite-Apps/Fluorite-Store
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyPushButton.py
48 lines (44 loc) · 1.12 KB
/
PyPushButton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from PySide6.QtCore import *
from PySide6.QtGui import *
from PySide6.QtWidgets import *
from PySide6.QtSvgWidgets import *
style = '''
QPushButton {{
border: none;
padding-left: 10px;
padding-right: 5px;
color: {_color};
border-radius: {_radius};
background-color: {_bg_color};
}}
QPushButton:hover {{
background-color: {_bg_color_hover};
}}
QPushButton:pressed {{
background-color: {_bg_color_pressed};
}}
'''
class PyPushButton(QPushButton):
def __init__(
self,
text,
radius,
color,
bg_color,
bg_color_hover,
bg_color_pressed,
parent = None,
):
super().__init__()
self.setText(text)
if parent != None:
self.setParent(parent)
self.setCursor(Qt.PointingHandCursor)
custom_style = style.format(
_color = color,
_radius = radius,
_bg_color = bg_color,
_bg_color_hover = bg_color_hover,
_bg_color_pressed = bg_color_pressed
)
self.setStyleSheet(custom_style)