Skip to content

Commit 559cde6

Browse files
Changed node widget color setting
Node widget colors are derived from the ViewerEnum.BACKGROUND_COLOR constant instead of the QPalette object. This prevents the text of the widgets being too dark.
1 parent 0eb0262 commit 559cde6

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

NodeGraphQt/widgets/node_widgets.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def setTitle(self, text):
1919
super(_NodeGroupBox, self).setTitle(text)
2020

2121
def setTitleAlign(self, align='center'):
22-
text_color = self.palette().text().color().getRgb()
22+
text_color = tuple(map(lambda i, j: i - j, (255, 255, 255),
23+
ViewerEnum.BACKGROUND_COLOR.value))
2324
style_dict = {
2425
'QGroupBox': {
2526
'background-color': 'rgba(0, 0, 0, 0)',
@@ -322,10 +323,10 @@ class NodeLineEdit(NodeBaseWidget):
322323

323324
def __init__(self, parent=None, name='', label='', text=''):
324325
super(NodeLineEdit, self).__init__(parent, name, label)
325-
plt = self.palette()
326-
bg_color = plt.alternateBase().color().getRgb()
327-
text_color = plt.text().color().getRgb()
328-
text_sel_color = plt.highlightedText().color().getRgb()
326+
bg_color = ViewerEnum.BACKGROUND_COLOR.value
327+
text_color = tuple(map(lambda i, j: i - j, (255, 255, 255),
328+
bg_color))
329+
text_sel_color = text_color
329330
style_dict = {
330331
'QLineEdit': {
331332
'background': 'rgba({0},{1},{2},20)'.format(*bg_color),
@@ -392,9 +393,23 @@ class NodeCheckBox(NodeBaseWidget):
392393
def __init__(self, parent=None, name='', label='', text='', state=False):
393394
super(NodeCheckBox, self).__init__(parent, name, label)
394395
_cbox = QtWidgets.QCheckBox(text)
396+
text_color = tuple(map(lambda i, j: i - j, (255, 255, 255),
397+
ViewerEnum.BACKGROUND_COLOR.value))
398+
style_dict = {
399+
'QCheckBox': {
400+
'color': 'rgba({0},{1},{2},150)'.format(*text_color),
401+
}
402+
}
403+
stylesheet = ''
404+
for css_class, css in style_dict.items():
405+
style = '{} {{\n'.format(css_class)
406+
for elm_name, elm_val in css.items():
407+
style += ' {}:{};\n'.format(elm_name, elm_val)
408+
style += '}\n'
409+
stylesheet += style
410+
_cbox.setStyleSheet(stylesheet)
395411
_cbox.setChecked(state)
396412
_cbox.setMinimumWidth(80)
397-
398413
font = _cbox.font()
399414
font.setPointSize(11)
400415
_cbox.setFont(font)

0 commit comments

Comments
 (0)