-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuto Type Input Text Colour Effects with Sound.py
More file actions
175 lines (138 loc) · 6.29 KB
/
Auto Type Input Text Colour Effects with Sound.py
File metadata and controls
175 lines (138 loc) · 6.29 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Auto Type Input Text Colour Effects with Sound Python program example.
# Created by Joseph C. Richardson, GitHub.com
# Please note: after you save your file, you must double click this file to view its cool
# coloured text effects and layout. Next, create a folder for your typing sound effect
# wave file and your Python file so they can execute/run together. Note: all sound files
# must be wave format; Python will not execute/run sound files in mp3 format, without
# importing a Python module for that, which I do not have at this moment.
# import these three Python modules below
import os,time,winsound
# Create a tuple variable for all seven colour values,
# starting at index 0 through index 6. Note: index numbers
# always start at 0, not 1. Be careful of how you count
# how many values you have within tuples and lists alike.
text_colours=(
'\x1b[31m', # index 0 = red
'\x1b[32m', # index 1 = green
'\x1b[33m', # index 2 = yellow
'\x1b[34m', # index 3 = blue
'\x1b[35m', # index 4 = purple
'\x1b[36m', # index 5 = cyan
'\x1b[37m' # index 6 = white
)
# Create some more variables to make programming less bulky
# and less code redundant on the programming part.
clear_screen='cls'
single_line_break='\n'
double_line_break='\n\n'
indent=' '*2
wave_sound='TYPE'
# Create a variable for an input() function text string value and a
# clear_screen variable that contains the os value 'cls' to clear the
# screen output, while executing/running the Python program.
input_text_words=(input(f'{single_line_break}{indent}Type some text \
and watch me type out what you typed:{double_line_break}{indent}'))
# forward autotype text
length=0
while length<=len(input_text_words):
for i in text_colours:
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
print(i+single_line_break+indent+input_text_words[:length])
time.sleep(.08)
os.system(clear_screen)
length+=1
print(text_colours[6]+single_line_break+indent+input_text_words)
input(f'{double_line_break}{indent}Press Enter to view the next example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# backward autotype text
os.system(clear_screen)
print(single_line_break+indent+input_text_words)
time.sleep(1)
length=0
while length<=len(input_text_words):
for i in text_colours:
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
print(i+single_line_break+indent+input_text_words[length:])
time.sleep(.08)
os.system(clear_screen)
length+=1
input(f'{double_line_break}{indent}Press Enter to view the next example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# forward outotype reverse text
length=0
while length<=len(input_text_words):
for i in text_colours:
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
print(i+single_line_break+indent+input_text_words[::-1][:length])
time.sleep(.08)
os.system(clear_screen)
length+=1
print(text_colours[6]+single_line_break+indent+input_text_words[::-1])
input(f'{double_line_break}{indent}Press Enter to view the next example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# backward outotype reverse text
os.system(clear_screen)
print(single_line_break+indent+input_text_words[::-1])
time.sleep(1)
length=0
while length<=len(input_text_words):
for i in text_colours:
winsound.PlaySound(wave_sound,winsound.SND_ASYNC)
print(i+single_line_break+indent+input_text_words[::-1][length:])
time.sleep(.08)
os.system(clear_screen)
length+=1
input(f'{double_line_break}{indent}Press Enter to view the bonus example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# I have one more text trick effect up my sleave that you're gonna
# like. This is how you can create a scrolling text marquee in Python.
indent=' '*4
delay=.08
text_variable='This is how you can create a scrolling text marquee in Python.'
for x in range(2):
for i in range(50):
print(double_line_break+indent+' '*i+text_variable)
time.sleep(delay)
os.system(clear_screen)
for j in range(i,-1,-1):
print(double_line_break+indent+' '*j+text_variable)
time.sleep(delay)
os.system(clear_screen)
print(double_line_break+indent+' '*j+text_variable)
input(f'{double_line_break}{indent}Press Enter to view the next bonus example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
indent=' '*4
delay=.08
text_variable='This is how you can create a scrolling text marquee in Python.'
for x in range(2):
for i in range(50):
print(double_line_break+indent+' '*i+text_variable)
time.sleep(delay)
os.system(clear_screen)
for j in range(i,-1,-1):
print(double_line_break+indent+' '*j+text_variable[::-1])
time.sleep(delay)
os.system(clear_screen)
print(double_line_break+indent+' '*j+text_variable[::-1])
input(f'{double_line_break}{indent}Press Enter to view the next bonus example:')
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
indent=' '*4
delay=.08
text_tuple_variable=(
'This is how you can create a scrolling text marquee in Python.',
'You can create a tuple or a list of text sentences to make a scrolling \
text marquee more fun.')
for x in range(2):
for i in range(50):
print(double_line_break+indent+' '*i+text_tuple_variable[0])
time.sleep(delay)
os.system(clear_screen)
for j in range(i,-1,-1):
print(double_line_break+indent+' '*j+text_tuple_variable[1])
time.sleep(delay)
os.system(clear_screen)
print(double_line_break+indent+' '*j+text_tuple_variable[1])
# Place an input() function so you can press the Enter key to close the
# Python program when you want to, without it closing right away after
# it's executed.
input(f'{double_line_break}{indent}Press Enter to exit and close this Python program example:')