forked from 4m1g0/Tiny-Uploader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.py
117 lines (90 loc) · 4.12 KB
/
gui.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPalette, QColor
from PyQt5.QtWidgets import QVBoxLayout, QWidget, QSizePolicy, QGroupBox, QSpinBox, QHBoxLayout, QDialog, QProgressBar, \
QPushButton, QButtonGroup, QDialogButtonBox, QLabel, QFrame, QProgressDialog
class VLayout(QVBoxLayout):
def __init__(self, margin=3, spacing=3):
super().__init__()
if isinstance(margin, int):
self.setContentsMargins(margin, margin, margin, margin)
elif isinstance(margin, list):
self.setContentsMargins(margin[0], margin[1], margin[2], margin[3])
self.setSpacing(spacing)
def addWidgets(self, widgets):
for w in widgets:
self.addWidget(w)
def addSpacer(self):
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.addWidget(spacer)
class HLayout(QHBoxLayout):
def __init__(self, margin=3, spacing=3):
super().__init__()
if isinstance(margin, int):
self.setContentsMargins(margin, margin, margin, margin)
elif isinstance(margin, list):
self.setContentsMargins(margin[0], margin[1], margin[2], margin[3])
self.setSpacing(spacing)
def addWidgets(self, widgets):
for w in widgets:
self.addWidget(w)
def addSpacer(self):
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.addWidget(spacer)
class GroupBoxV(QGroupBox):
def __init__(self, title, margin=3, spacing=3, *args, **kwargs):
super(GroupBoxV, self).__init__(*args, **kwargs)
self.setTitle(title)
layout = VLayout()
layout.setSpacing(spacing)
if isinstance(margin, int):
layout.setContentsMargins(margin, margin, margin, margin)
elif isinstance(margin, list):
layout.setContentsMargins(margin[0], margin[1], margin[2], margin[3])
self.setLayout(layout)
def addWidget(self, w):
self.layout().addWidget(w)
def addWidgets(self, widgets):
for w in widgets:
self.layout().addWidget(w)
def addLayout(self, w):
self.layout().addLayout(w)
class GroupBoxH(QGroupBox):
def __init__(self, title, margin=None, spacing=None, *args, **kwargs):
super(GroupBoxH, self).__init__(title)
self.setLayout(HLayout())
def addWidget(self, w):
self.layout().addWidget(w)
def addWidgets(self, widgets):
for w in widgets:
self.layout().addWidget(w)
def addLayout(self, w):
self.layout().addLayout(w)
class SpinBox(QSpinBox):
def __init__(self, *args, **kwargs):
super(SpinBox, self).__init__(*args, **kwargs)
self.setButtonSymbols(self.NoButtons)
self.setMinimum(kwargs.get('minimum', 1))
self.setMaximum(kwargs.get('maximum', 65535))
dark_palette = QPalette()
dark_palette.setColor(QPalette.Window, QColor(53, 53, 53))
dark_palette.setColor(QPalette.WindowText, Qt.white)
dark_palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127))
dark_palette.setColor(QPalette.Base, QColor(42, 42, 42))
dark_palette.setColor(QPalette.AlternateBase, QColor(66, 66, 66))
dark_palette.setColor(QPalette.ToolTipBase, Qt.white)
dark_palette.setColor(QPalette.ToolTipText, Qt.white)
dark_palette.setColor(QPalette.Text, Qt.white)
dark_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127))
dark_palette.setColor(QPalette.Dark, QColor(35, 35, 35))
dark_palette.setColor(QPalette.Shadow, QColor(20, 20, 20))
dark_palette.setColor(QPalette.Button, QColor(53, 53, 53))
dark_palette.setColor(QPalette.ButtonText, Qt.white)
dark_palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127))
dark_palette.setColor(QPalette.BrightText, Qt.red)
dark_palette.setColor(QPalette.Link, QColor(42, 130, 218))
dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
dark_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80))
dark_palette.setColor(QPalette.HighlightedText, Qt.white)
dark_palette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127))