Python Forum
Help with TypeWriter Effect in Python Rich
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with TypeWriter Effect in Python Rich
#1
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rich output to PDF HEbO61 1 194 Apr-16-2024, 07:30 AM
Last Post: Pedroski55
  Can rich.logging output to file? pyfoo 1 277 Mar-21-2024, 10:30 AM
Last Post: pyfoo
  Printing effect sizes for variables in an anova eyavuz21 2 991 Feb-01-2023, 02:12 PM
Last Post: eyavuz21
  Help adding prompt text in a Layout using Rich TUI Extra 2 1,664 May-23-2022, 07:15 PM
Last Post: Extra
  Rotation Effect on live Webcam Feed Leziiy 0 1,620 Sep-12-2020, 04:25 PM
Last Post: Leziiy
  How to fix statement seems to have no effect hernancrespo89 0 6,842 Jan-23-2020, 09:23 PM
Last Post: hernancrespo89
  strange effect from duplicating a file descriptor Skaperen 1 2,070 Feb-18-2019, 08:20 PM
Last Post: Skaperen
  Algorithm effect on the CPU Faruk 3 2,623 Dec-19-2018, 08:57 AM
Last Post: Faruk
  "Statement has no effect" birdieman 21 17,185 Jan-27-2017, 02:59 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020