1
from __future__ import print_function
6
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QSizePolicy
7
from PyQt5.QtSvg import QSvgWidget
10
class SquareSvgWidget(QSvgWidget):
11
def __init__(self, parent=None):
12
QSvgWidget.__init__(self, parent)
13
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
14
sizePolicy.setHeightForWidth(True)
15
self.setSizePolicy(sizePolicy)
17
def heightForWidth(self, width):
21
class StateBox(QWidget):
22
def __init__(self, parent, text=''):
23
QWidget.__init__(self, parent)
25
self.label = QLabel(text, self)
26
self.image = SquareSvgWidget(self)
28
layout = QHBoxLayout(self)
29
layout.setContentsMargins(0, 0, 0, 0)
30
layout.addWidget(self.image)
31
layout.addWidget(self.label)
36
def set_state(self, state):
40
name = "dialog-ok-apply.svg"
43
name = "edit-delete.svg"
44
icon = "/usr/share/icons/breeze/actions/22/" + name
45
if not os.path.isfile(icon):
46
icon = "/usr/share/icons/breeze/actions/toolbar/" + name
52
def set_property(self, prop, value):
54
self.label.setText(value)
56
print("qtwidgets.StateBox set_property() only implemented for "
57
"label", file=sys.stderr)