|
|
|
@ -2,7 +2,7 @@ import abc |
|
|
|
|
import pyray as rl |
|
|
|
|
from enum import IntEnum |
|
|
|
|
from collections.abc import Callable |
|
|
|
|
from typing import TypeVar, cast |
|
|
|
|
from typing import TypeVar |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DialogResult(IntEnum): |
|
|
|
@ -14,10 +14,8 @@ class DialogResult(IntEnum): |
|
|
|
|
T = TypeVar("T") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _resolve_value(value: T | Callable[[], T], default: T | str = "") -> T: |
|
|
|
|
if callable(value): |
|
|
|
|
return value() |
|
|
|
|
return value if value is not None else cast(T, default) |
|
|
|
|
def _resolve_value(value: T | Callable[[], T]) -> T: |
|
|
|
|
return value() if callable(value) else value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Widget(abc.ABC): |
|
|
|
@ -28,7 +26,7 @@ class Widget(abc.ABC): |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def is_visible(self) -> bool: |
|
|
|
|
return _resolve_value(self._is_visible, True) |
|
|
|
|
return _resolve_value(self._is_visible) |
|
|
|
|
|
|
|
|
|
def set_visible(self, visible: bool | Callable[[], bool]) -> None: |
|
|
|
|
self._is_visible = visible |
|
|
|
|