Welcome, guest | Sign In | My Account | Store | Cart

This DEMO shows how to fade text in shades of grey and also flash with inverse_flash along with simultaneous differing frequency beeps.

There are 2 code snippets that WILL need to be separated before use. One is a Linux version and the other a Windows 32 bit version. There is an AMIGA version but that is for much later.

There are NO notes inside the code so you will have to see the code as to how it works. It is SOOO simple that notes are/were unnecessary...

Bazza, G0LCU...

Python, 158 lines
  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
# Linux Version...
# Fade_Linux.py
#
# $VER: Fade_Linux.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.
#
# Written so that anyone can see and understand how it works! YES, it CAN be simplified considerably!!!
#
# This Linux version can easily be enhanced upon, e.g. cycling through colours...

import os
import sys
import time

# Ensure it works on just about all versions of Python...
if sys.version[0]=="3": raw_input=input

os.system("setterm -cursor off")
os.system("clear")
print("\nA DEMO to show fading and screen flashing...\n")
print("Press Ctrl-C to cycle through the test windows...\n")
print("$VER: Fade_Linux.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.\n")
raw_input("Press ENTER to Continue:- ")

def main():
	os.system("clear")
	while 1:
		try:
			print("\033[12;23f\033[30mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
			print("\033[12;23f\033[90mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
			print("\033[12;23f\033[37mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
			print("\033[12;23f\033[0mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
			print("\033[12;23f\033[37mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
			print("\033[12;23f\033[90mFading using four _shades_ of grey...\033[0m")
			time.sleep(0.1)
		except KeyboardInterrupt: break
	print("\033[13;1f    \033[12;22f\033[30m                                       \033[0m")
	time.sleep(0.5)
	audio=open("/dev/dsp","wb+")
	# This next window CANNOT be done in Windows using CMD.EXE as the Terminal!
	while 1:
		try:
			print("\033[12;36f\033[0;91;40mDANGER!!!\033[0m")
			time.sleep(0.1)
			for n in range(0,680,1): audio.write(b"\x00\x00\x00\x3F\x3F\x3F")
			print("\033[12;36f\033[0;30;101mDANGER!!!\033[0m")
			time.sleep(0.1)
			for n in range(0,500,1): audio.write(b"\x00\x00\x00\x00\x3F\x3F\x3F\x3F")
		except KeyboardInterrupt: break
	os.system("clear")
	audio.close()
	time.sleep(0.5)
	audio=open("/dev/dsp","wb+")
	while 1:
		try:
			print("\033[0;91;40m")
			os.system("clear")
			print("\033[12;36f\033[0;91;40mDANGER!!!")
			time.sleep(0.1)
			for n in range(0,680,1): audio.write(b"\x00\x00\x00\x3F\x3F\x3F")
			print("\033[0;30;101m")
			os.system("clear")
			print("\033[12;36f\033[0;30;101mDANGER!!!")
			time.sleep(0.1)
			for n in range(0,500,1): audio.write(b"\x00\x00\x00\x00\x3F\x3F\x3F\x3F")
		except KeyboardInterrupt: break
	print("\033[0m")
	os.system("clear")
	audio.close()
	time.sleep(0.5)
main()

os.system("setterm -cursor on")

print("\n$VER: Fade_Linux.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.\n")
print("Fading and flashing DEMO end...\n")

# End of Fade_Linux.py DEMO...
# Enjoy finding simple solutions to often very difficult problems... ;o)





# Windows Version...
# Fade_Windows.py
#
# $VER: Fade_Windows.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.
#
# Written so that anyone can see and understand how it works! YES, it CAN be simplified considerably!!!
#
# This Windows version is limited compared to the Linux version but my be of use...

import os
import sys
import time
import winsound

# Ensure it works on just about all versions of Python...
if sys.version[0]=="3": raw_input=input

os.system("CLS")
print("\nA DEMO to show fading and screen flashing...\n")
print("Press Ctrl-C to cycle through the test windows...\n")
raw_input("Using CMD.EXE as the CLI this is limited; press ENTER to Continue:- ")

def main():
	while 1:
		try:
			os.system("CLS")
			os.system("COLOR 07")
			print("\n\n\n\n\n\n\n\n\n\n\n                                                            ")
			time.sleep(0.05)
			os.system("CLS")
			os.system("COLOR 08")
			print("\n\n\n\n\n\n\n\n\n\n\n                    This is a test string to check fading...")
			time.sleep(0.05)
			os.system("CLS")
			os.system("COLOR 07")
			print("\n\n\n\n\n\n\n\n\n\n\n                    This is a test string to check fading...")
			time.sleep(0.05)
			os.system("CLS")
			os.system("COLOR 0F")
			print("\n\n\n\n\n\n\n\n\n\n\n                    This is a test string to check fading...")
			time.sleep(0.05)
			os.system("CLS")
			os.system("COLOR 07")
			print("\n\n\n\n\n\n\n\n\n\n\n                    This is a test string to check fading...")
			time.sleep(0.05)
			os.system("CLS")
			os.system("COLOR 08")
			print("\n\n\n\n\n\n\n\n\n\n\n                    This is a test string to check fading...")
			time.sleep(0.05)
		except KeyboardInterrupt: break
	while 1:
		try:
			os.system("COLOR C0")
			os.system("CLS")
			print("\n\n\n\n\n\n\n\n\n\n\n                                    DANGER!!!")
			winsound.Beep(1333,600)
			os.system("COLOR 0C")
			os.system("CLS")
			print("\n\n\n\n\n\n\n\n\n\n\n                                    DANGER!!!")
			winsound.Beep(1000,600)
		except KeyboardInterrupt: break
	os.system("COLOR 0F")
	os.system("CLS")
main()

print("\n$VER: Fade_Windows.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.\n")
print("Fading and flashing DEMO end...\n")

# End of Fade_Windows.py DEMO...
# Enjoy finding simple solutions to often very difficult problems... ;o)

Another DEMO to enhance text mode Python code.

The Windows version is limited to full screen facilities ONLY and cannot have more than two colours inside a CMD.EXE Python window; therefore the second part of the Linux DEMO is unable to be reproduced. Also the fading effect will also fade the whole Python window inside a Windows run.

Linux however does not have these restrictions so......

Enjoy finding simple solutions to often very difficult problems...

Bazza, G0LCU...

1 comment

Barry Walker (author) 9 years, 4 months ago  # | flag

I forgot to add that the code assumes a Python window of white on black...

Bazza, G0LCU...