diff --git a/tkintertools/core/configs.py b/tkintertools/core/configs.py index c4675dc4..94c854ff 100644 --- a/tkintertools/core/configs.py +++ b/tkintertools/core/configs.py @@ -40,6 +40,8 @@ class Env: is_dark: bool default_callback: collections.abc.Callable[[tkinter.Event], typing.Literal[False]] + enable_animation: bool + default_root = _DefaultRootDescriptor() @classmethod @@ -47,6 +49,7 @@ def reset(cls) -> None: """Reset all configs.""" cls.system = cls.get_default_system() cls.is_dark = bool(darkdetect.isDark()) if globals().get("darkdetect") else False + cls.enable_animation = True cls.default_callback = lambda _: False @staticmethod diff --git a/tkintertools/core/virtual.py b/tkintertools/core/virtual.py index b9a38a7c..ff038fd2 100644 --- a/tkintertools/core/virtual.py +++ b/tkintertools/core/virtual.py @@ -437,7 +437,7 @@ def __init__( state: str = "normal", anchor: typing.Literal["n", "s", "w", "e", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -464,7 +464,7 @@ def __init__( self.state = state self.anchor = anchor self.through = self.is_nested() if through is None else through - self.animation = animation + self.animation = configs.Env.enable_animation if animation is None else animation self.widgets: list[Widget] = [] self.texts: list[Text] = [] diff --git a/tkintertools/standard/widgets.py b/tkintertools/standard/widgets.py index 568c618a..67ab071f 100644 --- a/tkintertools/standard/widgets.py +++ b/tkintertools/standard/widgets.py @@ -52,7 +52,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -101,7 +101,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -161,7 +161,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -221,7 +221,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -275,7 +275,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -346,7 +346,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -430,7 +430,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -497,7 +497,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -566,7 +566,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -631,7 +631,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -767,7 +767,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -821,7 +821,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -876,7 +876,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -958,7 +958,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -1059,7 +1059,7 @@ def __init__( name: str | None = None, anchor: typing.Literal["n", "e", "w", "s", "nw", "ne", "sw", "se", "center"] = "nw", through: bool | None = None, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `master`: parent canvas @@ -1138,6 +1138,10 @@ def clear(self) -> None: self.widgets[0].clear() +class OptionButton(virtual.Widget): + """A button that has many options to choose""" + + class Tooltip(virtual.Widget): """A tooltip that can display additional information""" @@ -1158,7 +1162,7 @@ def __init__( justify: typing.Literal["left", "center", "right"] = "left", name: str | None = None, through: bool = True, - animation: bool = True, + animation: bool | None = None, ) -> None: """ * `widget`: the associated widget