Color-specialized QLineEdit layout
| 104 | |
| 105 | |
| 106 | class ColorLayout(QtWidgets.QHBoxLayout): |
| 107 | """Color-specialized QLineEdit layout""" |
| 108 | def __init__(self, color, parent=None): |
| 109 | super().__init__() |
| 110 | assert isinstance(color, QtGui.QColor) |
| 111 | self.lineedit = QtWidgets.QLineEdit( |
| 112 | mcolors.to_hex(color.getRgbF(), keep_alpha=True), parent) |
| 113 | self.lineedit.editingFinished.connect(self.update_color) |
| 114 | self.addWidget(self.lineedit) |
| 115 | self.colorbtn = ColorButton(parent) |
| 116 | self.colorbtn.color = color |
| 117 | self.colorbtn.colorChanged.connect(self.update_text) |
| 118 | self.addWidget(self.colorbtn) |
| 119 | |
| 120 | def update_color(self): |
| 121 | color = self.text() |
| 122 | qcolor = to_qcolor(color) # defaults to black if not qcolor.isValid() |
| 123 | self.colorbtn.color = qcolor |
| 124 | |
| 125 | def update_text(self, color): |
| 126 | self.lineedit.setText(mcolors.to_hex(color.getRgbF(), keep_alpha=True)) |
| 127 | |
| 128 | def text(self): |
| 129 | return self.lineedit.text() |
| 130 | |
| 131 | |
| 132 | def font_is_installed(font): |
no outgoing calls
no test coverage detected
searching dependent graphs…