# demo-clock.py
# These list assignments can be done on single lines, but it's much easier to see what
# these values represent by doing it this way.
space = [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "]
colon = [
" ",
" ",
" ::: ",
" ::: ",
" ",
" ",
" ::: ",
" ::: ",
" ",
" "]
forwardSlash = [
" ",
" //",
" // ",
" // ",
" // ",
" // ",
" // ",
" // ",
"// ",
" "]
number0 = [
" 000000 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 00 00 ",
" 000000 "]
number1 = [
" 11 ",
" 111 ",
" 1111 ",
" 11 ",
" 11 ",
" 11 ",
" 11 ",
" 11 ",
" 11 ",
" 111111 "]
number2 = [
" 222222 ",
" 22 22 ",
" 22 22 ",
" 22 ",
" 22 ",
" 22 ",
" 22 ",
" 22 ",
" 22 ",
" 22222222 "]
number3 = [
" 333333 ",
" 33 33 ",
" 33 33 ",
" 33 ",
" 3333 ",
" 33 ",
" 33 ",
" 33 33 ",
" 33 33 ",
" 333333 "]
number4 = [
" 44 ",
" 444 ",
" 4444 ",
" 44 44 ",
" 44 44 ",
"444444444 ",
" 44 ",
" 44 ",
" 44 ",
" 44 "]
number5 = [
" 55555555 ",
" 55 ",
" 55 ",
" 55 ",
" 55555555 ",
" 55 ",
" 55 ",
" 55 ",
" 55 ",
" 55555555 "]
number6 = [
" 666666 ",
" 66 66 ",
" 66 ",
" 66 ",
" 6666666 ",
" 66 66 ",
" 66 66 ",
" 66 66 ",
" 66 66 ",
" 666666 "]
number7 = [
" 77777777 ",
" 77 ",
" 77 ",
" 77 ",
" 77 ",
" 77 ",
" 77 ",
" 77 ",
" 77 ",
" 77 "]
number8 = [
" 888888 ",
" 88 88 ",
" 88 88 ",
" 88 88 ",
" 888888 ",
" 88 88 ",
" 88 88 ",
" 88 88 ",
" 88 88 ",
" 888888 "]
number9 = [
" 999999 ",
" 99 99 ",
" 99 99 ",
" 99 99 ",
" 999999 ",
" 99 ",
" 99 ",
" 99 ",
" 99 99 ",
" 999999 "]
import curses
import math
import sys
import datetime
def putChar(windowObj, inChar, inAttr = 0):
#windowObj.box()
#windowObj.addstr(inChar)
# The logic below maps the normal character input to a list which contains a "big"
# representation of that character.
charToPut = ""
if '0' == inChar:
charToPut = number0
elif '1' == inChar:
charToPut = number1
elif '2' == inChar:
charToPut = number2
elif '3' == inChar:
charToPut = number3
elif '4' == inChar:
charToPut = number4
elif '5' == inChar:
charToPut = number5
elif '6' == inChar:
charToPut = number6
elif '7' == inChar:
charToPut = number7
elif '8' == inChar:
charToPut = number8
elif '9' == inChar:
charToPut = number9
elif ':' == inChar:
charToPut = colon
elif "https://dzone.com/" == inChar:
charToPut = forwardSlash
elif ' ' == inChar:
charToPut = space
lineCount = 0
# This loop will iterate each line in the window to display a "line" of the digit
# to be displayed.
for line in charToPut:
# Attributes, or the bitwise combinations of multiple attributes, are passed as-is
# into addstr. Note that not all attributes, or combinations of attributes, will
# work with every terminal.
windowObj.addstr(lineCount, 0, charToPut[lineCount], inAttr)
lineCount = 1 + lineCount
windowObj.refresh()
def main(argv):
# Initialize the curses object.
stdscr = curses.initscr()
# Do not echo keys back to the client.
curses.noecho()
# Non-blocking or cbreak mode... do not wait for Enter key to be pressed.
curses.cbreak()
# Turn off blinking cursor
curses.curs_set(False)
# Enable color if we can...
if curses.has_colors():
curses.start_color()
# Optional - Enable the keypad. This also decodes multi-byte key sequences
# stdscr.keypad(True)
caughtExceptions = ""
try:
# First things first, make sure we have enough room!
if curses.COLS