Make GUI not rely on bool(), remove BoundWidget.__bool__() (#251)

pull/357/head
nyanpasu64 2019-04-01 04:03:22 -07:00 zatwierdzone przez GitHub
rodzic bd34d5cf93
commit 323ce36137
2 zmienionych plików z 5 dodań i 14 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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: