kopia lustrzana https://github.com/corrscope/corrscope
Make GUI not rely on bool(), remove BoundWidget.__bool__() (#251)
rodzic
bd34d5cf93
commit
323ce36137
|
|
@ -195,14 +195,6 @@ class BoundWidget(QWidget):
|
|||
if updater != self.cfg2gui:
|
||||
updater()
|
||||
|
||||
def __bool__(self):
|
||||
"""
|
||||
qw.QComboBox().__bool__ does not exist,
|
||||
yet bool(qw.QComboBox()) == False.
|
||||
I suspect https://docs.python.org/3/c-api/bool.html is involved.
|
||||
"""
|
||||
return True
|
||||
|
||||
|
||||
def blend_colors(
|
||||
color1: QColor, color2: QColor, ratio: float, gamma: float = 2
|
||||
|
|
|
|||
|
|
@ -218,8 +218,7 @@ Right = TypeVar("Right", bound=Union[QWidget, QLayout]) # same as WidgetOrLayou
|
|||
|
||||
|
||||
class _Both:
|
||||
def __bool__(self):
|
||||
return False
|
||||
pass
|
||||
|
||||
|
||||
Both = _Both()
|
||||
|
|
@ -233,18 +232,18 @@ def widget_pair_inserter(append_widgets: Callable):
|
|||
if right_type is Both:
|
||||
left = create_element(left_type, parent, kwargs)
|
||||
right = Both
|
||||
push = left
|
||||
child = left
|
||||
else:
|
||||
left = create_element(left_type, parent)
|
||||
right = create_element(right_type, parent, kwargs)
|
||||
push = right
|
||||
child = right
|
||||
|
||||
if name:
|
||||
(right or left).setObjectName(name)
|
||||
child.setObjectName(name)
|
||||
|
||||
left_is_label = isinstance(left, QLabel)
|
||||
|
||||
with stack.push(push):
|
||||
with stack.push(child):
|
||||
if right is Both:
|
||||
yield left
|
||||
elif left_is_label:
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue