Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text, one letter at a time
#1
So I used to know how to do this thing where my text would be typed at a speed of 0.1 instead of immediately. But now I have forgotten it. I use to use it in games but those games were deleted. This is most of what is left. The ? is what I forgot.

def textType(text, delay):
     for ch in ???
     ??????????????
     print ("")

textType("Hello", 0.1)
HELP ME! Pray Pray Pray
Reply
#2
In Python, or a different language? Did it use curses? Was it platform-dependent?
Reply
#3
Yes, it was in Python.

And No Curses

So this is what it would have looked like in a game...

#top of code
import time
gold = 0

#This is when it was in.
def textType(text, delay):
     for ch in ?????
     ?????????????
     print("")

def start():
     
     textType("Hello", 0.1)
     name = input("What is your name?")
#Bla bla bla etc.
Reply
#4
Misread your question. I think you want time.sleep(). Was thinking you wanted something people were typing into their terminal echoed back slowly, but you just want to print a whole string you already have more slowly?
Reply
#5
OMG!!! YESSS!!! I REMEMBER!! Thank you. That's it
Reply
#6
Wait, wait, wait. How would I use
 time.sleep(0.1) 
with the
 def textType 
function?

Like if I used it this way:

for ch in text:
    print (ch)
    time.sleep(0.1)

textType("Hello Everybody!", 0.1)
Reply
#7
In function:
time.sleep(delay)
Reply
#8
(Oct-31-2016, 10:01 PM)MACA Wrote: Wait, wait, wait. How would I use
 time.sleep(0.1) 
with the
 def textType 
function?

Like if I used it this way:

for ch in text:
    print (ch)
    time.sleep(0.1)

textType("Hello Everybody!", 0.1)
Hello!
The default behavior of print() functions is to add \n - a new line - character at the end of the printed text. So the next printed text will be printed bellow.
print(ch, end="")
will fix it. The default is end="\n"
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  More elegant way to remove time from text lines. Pedroski55 6 4,175 Apr-25-2021, 03:18 PM
Last Post: perfringo
  Split gps files based on time (text splitting) dervast 0 1,964 Nov-09-2020, 09:19 AM
Last Post: dervast
  [Help] How to count Letter frequency in a text file? vanicci 6 15,926 Aug-08-2018, 12:23 PM
Last Post: vanicci

Forum Jump:

User Panel Messages

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