Python Forum

Full Version: Help with TypeWriter Effect in Python Rich
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to have the text look like it's being typed live on the screen using the typewriter effect. I got it to print to the terminal the way I want it but I'm wondering how to have it print inside the Panel I created using Rich.

Is that possible?
If so, how do I do it?

Thanks in advance.

The code
import sys
import time
from rich import print
from rich.panel import Panel
from rich.text import Text

def ComputerOutput(text):
    output = Text(text)
    output.stylize("bold green")
    print("\n")
    print(Panel(output, title="[green]Computer"))

ComputerOutput("This will print inside the Panel/box")

results = "At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum"

print("Computer: ", end="")
for i in results:
    sys.stdout.write(i)
    sys.stdout.flush()
    time.sleep(0.05)
print("\n")

#How do I get results to auto type (typewriter effect) inside the box -> ComputerOutput()