width of Lighting button is not so complicated to set and ton size is default to 8pt

This commit is contained in:
iLLiCiTiT 2019-12-10 14:32:28 +01:00
parent 06a2144b72
commit bc9e7833b0

View file

@ -308,14 +308,15 @@ class ComponentItem(QtWidgets.QFrame):
class LightingButton(QtWidgets.QPushButton):
lightingbtnstyle = """
QPushButton {
font: %(font_size_pt)spt;
text-align: center;
color: #777777;
background-color: transparent;
border-width: 1px;
border-color: #777777;
border-style: solid;
padding-top: 2px;
padding-bottom: 2px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 3px;
padding-right: 3px;
border-radius: 3px;
@ -351,14 +352,11 @@ class LightingButton(QtWidgets.QPushButton):
color: #4BF543;
}
"""
def __init__(self, text, *args, **kwargs):
super().__init__(text, *args, **kwargs)
self.setStyleSheet(self.lightingbtnstyle)
def __init__(self, text, font_size_pt=8, *args, **kwargs):
super(LightingButton, self).__init__(text, *args, **kwargs)
self.setStyleSheet(self.lightingbtnstyle % {
"font_size_pt": font_size_pt
})
self.setCheckable(True)
preview_font_metrics = self.fontMetrics().boundingRect(text)
width = preview_font_metrics.width() + 16
height = preview_font_metrics.height() + 5
self.setMaximumWidth(width)
self.setMaximumHeight(height)