Wobbly-Website/files/python/ematrix/ematrix1.1.py
2023-07-30 18:32:42 +02:00

210 lines
No EOL
8 KiB
Python

import os
import random
import time
import settings
loop = 1
while loop == 1:
os.system("clear")
fillscreen = settings.fillscreen
while fillscreen > 0:
fillscreen = fillscreen - 1
try:
charornum = random.randrange(1,3)
if charornum == 1:
numcharacter = random.randrange(1,51)
if numcharacter == 1:
character = "A"
if numcharacter == 2:
character = "B"
if numcharacter == 3:
character = "C"
if numcharacter == 4:
character = "D"
if numcharacter == 5:
character = "E"
if numcharacter == 6:
character = "F"
if numcharacter == 7:
character = "G"
if numcharacter == 8:
character = "H"
if numcharacter == 9:
character = "I"
if numcharacter == 10:
character = "J"
if numcharacter == 11:
character = "K"
if numcharacter == 12:
character = "L"
if numcharacter == 13:
character = "M"
if numcharacter == 14:
character = "N"
if numcharacter == 15:
character = "O"
if numcharacter == 16:
character = "P"
if numcharacter == 17:
character = "Q"
if numcharacter == 18:
character = "R"
if numcharacter == 19:
character = "S"
if numcharacter == 20:
character = "T"
if numcharacter == 21:
character = "U"
if numcharacter == 22:
character = "V"
if numcharacter == 23:
character = "W"
if numcharacter == 24:
character = "X"
if numcharacter == 25:
character = "Y"
if numcharacter == 26:
character = "Z"
if numcharacter > 26 and numcharacter < 33:
character = " "
if numcharacter == 33:
character = "("
if numcharacter == 34:
character = ")"
if numcharacter == 35:
character = "%"
if numcharacter == 36:
character = "$"
if numcharacter == 37:
character = "!"
if numcharacter == 38:
character = "/"
if numcharacter == 39:
character = "&"
if numcharacter == 40:
character = "="
if numcharacter == 41:
character = "#"
if numcharacter == 42:
character = "*"
if numcharacter == 43:
character = "+"
if numcharacter == 44:
character = "-"
if numcharacter == 45:
character = "<"
if numcharacter == 46:
character = ">"
if numcharacter == 47:
character = "§"
if numcharacter == 48:
character = "?"
if numcharacter == 49:
character = "["
if numcharacter == 50:
character = "]"
grorwh = random.randrange(1,3)
if grorwh == 1:
print("\033[0;32m" + character + "\033[0m", end="", flush="true")
if grorwh == 2:
print("\033[1;37m" + character + "\033[0m", end="", flush="true")
if charornum == 2:
grorwh = random.randrange(1,4)
if grorwh == 1:
print("\033[0;32m" + str(random.randrange(0,10)) + "\033[0m", end="", flush="true")
if grorwh == 2:
print("\033[1;32m" + str(random.randrange(0,10)) + "\033[0m", end="", flush="true")
if grorwh == 3:
print("\033[1;37m" + str(random.randrange(0,10)) + "\033[0m", end="", flush="true")
time.sleep(settings.interval)
except KeyboardInterrupt:
try:
os.system("clear")
waitingforcommand = 1
while waitingforcommand == 1:
command = input("Please enter a Command: ")
if command == "help" or command == "changescreensize" or command == "ctioc":
if command == "help":
print("\nCommands:\n")
print("help - Shows this here.")
print("changescreensize - Changes the number of characters to fill the terminal.")
print('ctioc - "c" for "change" "t" for "the" "i" for "interval" "o" for "of"')
print(' and "c" for "characters" = Change the interval of characters.\n')
if command == "changescreensize":
new_size = input("Please enter a new number: ")
read_settings_for_size_save = open(os.path.realpath(__file__) + "/settings.py", "r")
old_settings_for_size_save = read_settings_for_size_save.read()
read_settings_for_size_save.close()
new_settings_for_size_save = old_settings_for_size_save.replace("fillscreen = " + str(settings.fillscreen), "fillscreen = " + new_size)
save_new_size = open(os.path.realpath(__file__) + "/settings.py", "w")
save_new_size.write(new_settings_for_size_save)
save_new_size.close()
print("Successfully saved.")
print("Please restart.")
loop = 0
fillscreen = 0
waitingforcommand = 0
if command == "ctioc":
new_interval = input("Please specify the new interval in seconds\n(If less than one second then with dot e.b. so: 0.001)\n(Warning: if the number after the point is too long\n e.b. so: 0.000001 the CPU is heavily loaded.): ")
read_settings_for_interval_save = open(os.path.dirname(os.path.realpath(__file__)) + "/settings.py", "r")
old_settings_for_interval_save = read_settings_for_interval_save.read()
read_settings_for_interval_save.close()
new_settings_for_interval_save = old_settings_for_interval_save.replace("interval = " + str(settings.interval), "interval = " + new_interval)
save_new_interval = open(os.path.dirname(os.path.realpath(__file__)) + "/settings.py", "w")
save_new_interval.write(new_settings_for_interval_save)
save_new_interval.close()
print("Successfully saved.")
print("Please restart.")
loop = 0
fillscreen = 0
waitingforcommand = 0
else:
waitingforcommand = 0
except KeyboardInterrupt:
os.system("clear")
print("Program stopped.")
loop = 0
fillscreen = 0
time.sleep(0.1)