How to use the yaspin.spinners.Spinners function in yaspin

To help you get started, we’ve selected a few yaspin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pavdmyt / yaspin / examples / demo.py View on Github external
def colors_simple(sleep=0.7):
    # Setup printing
    max_len = 25
    msg = "[Colors]"

    with yaspin(Spinners.dots12) as sp:
        for color in COLORS:
            spaces_qty = max_len - len(color) - len(msg)
            text = "{0}{1}{2}".format(color, " " * spaces_qty, msg)

            sp.color = color
            sp.text = text
            time.sleep(sleep)
github pavdmyt / yaspin / examples / demo.py View on Github external
def reversed_spinner(sleep=1):
    with yaspin(text="Reversed spinner", reversal=True, color="cyan") as sp:
        time.sleep(sleep)

        sp.spinner = Spinners.line

        time.sleep(sleep)

        sp.text = "Enjoy!"
        sp.ok("☀️ ")
github pavdmyt / yaspin / examples / reverse_spinner.py View on Github external
def main():
    with yaspin(Spinners.clock, text="Clockwise") as sp:

        # Clockwise rotation
        time.sleep(3)

        # Reverse spin direction
        sp.reversal = True
        sp.text = "Counterclockwise"

        # Counterclockwise rotation
        time.sleep(3)
github pavdmyt / yaspin / yaspin / core.py View on Github external
def __getattr__(self, name):
        # CLI spinners
        if name in SPINNER_ATTRS:
            from .spinners import Spinners

            sp = getattr(Spinners, name)
            self.spinner = sp
        # Color Attributes: "color", "on_color", "attrs"
        elif name in COLOR_ATTRS:
            attr_type = COLOR_MAP[name]
            # Call appropriate property setters;
            # _color_func is updated automatically by setters.
            if attr_type == "attrs":
                self.attrs = [name]  # calls property setter
            if attr_type in ("color", "on_color"):
                setattr(self, attr_type, name)  # calls property setter
        # Side: "left" or "right"
        elif name in ("left", "right"):
            self.side = name  # calls property setter
        # Common error for unsupported attributes
        else:
            raise AttributeError(
github pavdmyt / yaspin / examples / demo.py View on Github external
("clock", 0.7),
        ("earth", 0.7),
        ("moon", 0.7),
        ("runner", 0.5),
        ("pong", 1),
        ("shark", 1.5),
        ("christmas", 0.5),
    ]
    random.shuffle(params)

    # Setup printing
    max_len = 45
    msg = "[Any spinner you like]"

    for name, period in params:
        spinner = getattr(Spinners, name)

        spaces_qty = max_len - len(name) - len(msg) - len(spinner.frames[0])
        text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)

        with yaspin(spinner, text=text, color="cyan"):
            time.sleep(period)