跳转至

tkintertools.animation.animations

字数 717 个   代码 111 行   阅读时间 4 分钟   访问量

Standard animation classes

The built-in basic animation classes are: MoveTkWidget, MoveWidget, MoveComponent, MoveItem, GradientTkWidget, GradientItem, ScaleFontSize

🟢Animation

class public | object

def __init__(
    self,
    ms: int,
    controller: typing.Callable[[float], float],
    *,
    callback: typing.Optional[typing.Callable[[float], typing.Any]] = None,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
    derivation: bool = False,
) -> None: ...
Animation base class

  • ms: duration of the animation, in milliseconds
  • controller: control functions that determine the course of the entire animation movement
  • callback: callback function, which will be called once per frame, with the parameter being the percentage of the current animation progress
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation
  • derivation: whether the callback function is derivative

🟡_wrapper

method protected

1
2
3
4
def _wrapper(
    self,
    func: typing.Callable[[float], float],
) -> typing.Callable[[float], float]: ...

Make the ending function call correctly

  • func: the callback function to be wrapped

🟡start

method public

1
2
3
4
5
def start(
    self,
    *,
    delay: int = 0,
) -> None: ...

Start the animation

  • delay: length of the delay before the animation starts, in milliseconds

🟡stop

method public

1
2
3
def stop(
    self,
) -> None: ...
Stop the animation

🟢GradientItem

class public | Animation

def __init__(
    self,
    canvas: Canvas,
    item: int,
    parameter: str,
    ms: int,
    colors: tuple[str, str],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
    derivation: bool = False,
) -> None: ...
Animation that makes color of canvas item gradient

  • canvas: an instance of tkinter.Canvas that contains the item
  • item: item whose color is to be gradient
  • parameter: parameter name of the part of the item that needs to be modified in color
  • ms: duration of the animation, in milliseconds
  • colors: a tuple of the initial and ending colors
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation
  • derivation: whether the callback function is derivative

🟢GradientTkWidget

class public | Animation

def __init__(
    self,
    widget: Widget,
    parameter: str,
    ms: int,
    colors: tuple[str, str],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
    derivation: bool = False,
) -> None: ...
Animation that makes color of tkinter.Widget gradient

  • widget: tkinter widget whose color is to be gradient
  • parameter: parameter name of the part of the item that needs to be modified in color
  • ms: duration of the animation, in milliseconds
  • colors: a tuple of the initial and ending colors
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation
  • derivation: whether the callback function is derivative

🟢MoveComponent

class public | Animation

def __init__(
    self,
    component: virtual.Component,
    ms: int,
    offset: tuple[float, float],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
) -> None: ...
Animation of moving Component

  • component: component to be moved
  • ms: duration of the animation, in milliseconds
  • offset: relative offset of the coordinates
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation

🟢MoveItem

class public | Animation

def __init__(
    self,
    canvas: Canvas,
    item: int,
    ms: int,
    offset: tuple[float, float],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
) -> None: ...
Animation of moving a item

  • canvas: an instance of tkinter.Canvas that contains the item
  • item: the item to be moved
  • ms: duration of the animation, in milliseconds
  • offset: relative offset of the coordinates
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation

🟢MoveTkWidget

class public | Animation

def __init__(
    self,
    widget: Widget,
    ms: int,
    offset: tuple[float, float],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
) -> None: ...
Animation of moving tkinter.Widget

  • widget: tkinter widget to be moved
  • ms: duration of the animation, in milliseconds
  • offset: relative offset of the coordinates
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation

🟢MoveWidget

class public | Animation

def __init__(
    self,
    widget: virtual.Widget,
    ms: int,
    offset: tuple[float, float],
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
) -> None: ...
Animation of moving Widget

  • widget: widget to be moved
  • ms: duration of the animation, in milliseconds
  • offset: relative offset of the coordinates
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation

🟢ScaleFontSize

class public | Animation

def __init__(
    self,
    text: virtual.Text,
    ms: int,
    sizes: tuple[float, float] | float,
    *,
    controller: typing.Callable[[float], float] = flat,
    end: typing.Optional[typing.Callable[[], typing.Any]] = None,
    repeat: int = 0,
    fps: int = 30,
    derivation: bool = False,
) -> None: ...
Animation of scaling the font size

  • text: an instance of virtual.Text that needs to be scaled in font size
  • ms: duration of the animation, in milliseconds
  • sizes: a tuple of the initial and ending sizes or target font size
  • controller: control functions that determine the course of the entire animation movement
  • end: ending function, which is called once at the end of the animation
  • repeat: number of repetitions of the entire animation process
  • fps: the FPS of the animation
  • derivation: whether the callback function is derivative

🟡_scale

method protected

1
2
3
4
def _scale(
    self,
    size: int,
) -> None: ...
Scale font size