This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_displayer.py
54 lines (47 loc) · 1.75 KB
/
text_displayer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from time import sleep
class TextDisplayer:
def __init__(self):
pass
# n秒おきにテキストを表示する
def printI(self, text: str, interval: float):
texts = list(text)
for text in texts:
print(text, flush=True, end="")
sleep(interval)
# n秒間かけてテキストを表示する
def printD(self, text: str, duration: float):
texts = list(text)
interval = duration / len(texts)
for text in texts:
print(text, flush=True, end="")
sleep(interval)
# 行ごとにn秒おきにテキストを表示する
def printIL(self, text: str, interval: float):
lines = text.strip().split("\n")
for line in lines:
print(line)
sleep(interval)
# 行ごとにn秒間かけてテキストを表示する
def printDL(self, text: str, duration: float):
lines = text.strip().split("\n")
interval = duration / len(lines)
for line in lines:
print(line)
sleep(interval)
# n秒おきにテキストを表示後、入力させる
def inputI(self, text: str, interval: float):
texts = list(text)
for text in texts:
print(text, flush=True, end="")
sleep(interval)
input_content = input("")
return input_content
# n秒間かけてテキストを表示後、入力させる
def inputD(self, text: str, duration: float):
texts = list(text)
interval = duration / len(texts)
for text in texts:
print(text, flush=True, end="")
sleep(interval)
input_content = input("")
return input_content