no need to make it too generic

pull/35543/head
Shane Smiskol 3 months ago
parent e5293c3f48
commit 98bfd45712
  1. 10
      system/ui/lib/widget.py

@ -2,7 +2,6 @@ import abc
import pyray as rl
from enum import IntEnum
from collections.abc import Callable
from typing import TypeVar
class DialogResult(IntEnum):
@ -11,13 +10,6 @@ class DialogResult(IntEnum):
NO_ACTION = -1
T = TypeVar("T")
def _resolve_value(value: T | Callable[[], T]) -> T:
return value() if callable(value) else value
class Widget(abc.ABC):
def __init__(self):
self._rect: rl.Rectangle = rl.Rectangle(0, 0, 0, 0)
@ -26,7 +18,7 @@ class Widget(abc.ABC):
@property
def is_visible(self) -> bool:
return _resolve_value(self._is_visible)
return self._is_visible() if callable(self._is_visible) else self._is_visible
def set_visible(self, visible: bool | Callable[[], bool]) -> None:
self._is_visible = visible

Loading…
Cancel
Save