summaryrefslogtreecommitdiffstats
path: root/Demo/curses
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 05:56:09 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 05:56:09 (GMT)
commite6ddc8b20b493fef2e7cffb2e1351fe1d238857e (patch)
tree3b3d8fcd92e1d8f0cad44297d5c2ae8522bb984c /Demo/curses
parent4fba4521e836e0cab08316592392b1e4d06eb6ef (diff)
downloadcpython-e6ddc8b20b493fef2e7cffb2e1351fe1d238857e.zip
cpython-e6ddc8b20b493fef2e7cffb2e1351fe1d238857e.tar.gz
cpython-e6ddc8b20b493fef2e7cffb2e1351fe1d238857e.tar.bz2
Whitespace normalization. Ran reindent.py over the entire source tree.
Diffstat (limited to 'Demo/curses')
-rwxr-xr-xDemo/curses/life.py281
-rw-r--r--Demo/curses/ncurses.py4
-rw-r--r--Demo/curses/rain.py24
-rw-r--r--Demo/curses/tclock.py8
-rw-r--r--Demo/curses/xmas.py274
5 files changed, 295 insertions, 296 deletions
diff --git a/Demo/curses/life.py b/Demo/curses/life.py
index 4ce09d2..a787e26 100755
--- a/Demo/curses/life.py
+++ b/Demo/curses/life.py
@@ -11,7 +11,7 @@
# Cursor keys : Move the cursor around the board
# Space or Enter : Toggle the contents of the cursor's position
#
-# TODO :
+# TODO :
# Support the mouse
# Use colour if available
# Make board updates faster
@@ -26,11 +26,11 @@ class LifeBoard:
Attributes:
X,Y : horizontal and vertical size of the board
state : dictionary mapping (x,y) to 0 or 1
-
+
Methods:
- display(update_board) -- If update_board is true, compute the
+ display(update_board) -- If update_board is true, compute the
next generation. Then display the state
- of the board and refresh the screen.
+ of the board and refresh the screen.
erase() -- clear the entire board
makeRandom() -- fill the board randomly
set(y,x) -- set the given cell to Live; doesn't refresh the screen
@@ -39,90 +39,90 @@ class LifeBoard:
"""
def __init__(self, scr, char=ord('*')):
- """Create a new LifeBoard instance.
-
- scr -- curses screen object to use for display
- char -- character used to render live cells (default: '*')
- """
- self.state={} ; self.scr=scr
- Y, X = self.scr.getmaxyx()
- self.X, self.Y = X-2, Y-2-1
- self.char = char
- self.scr.clear()
-
- # Draw a border around the board
- border_line='+'+(self.X*'-')+'+'
- self.scr.addstr(0, 0, border_line)
- self.scr.addstr(self.Y+1,0, border_line)
- for y in range(0, self.Y):
- self.scr.addstr(1+y, 0, '|')
- self.scr.addstr(1+y, self.X+1, '|')
- self.scr.refresh()
-
- def set(self, y, x):
- """Set a cell to the live state"""
- if x<0 or self.X<=x or y<0 or self.Y<=y:
- raise ValueError, "Coordinates out of range %i,%i"% (y,x)
- self.state[x,y] = 1
-
- def toggle(self, y, x):
- """Toggle a cell's state between live and dead"""
- if x<0 or self.X<=x or y<0 or self.Y<=y:
- raise ValueError, "Coordinates out of range %i,%i"% (y,x)
- if self.state.has_key( (x,y) ):
- del self.state[x,y]
- self.scr.addch(y+1, x+1, ' ')
- else:
- self.state[x,y]=1
- self.scr.addch(y+1, x+1, self.char)
- self.scr.refresh()
+ """Create a new LifeBoard instance.
+
+ scr -- curses screen object to use for display
+ char -- character used to render live cells (default: '*')
+ """
+ self.state={} ; self.scr=scr
+ Y, X = self.scr.getmaxyx()
+ self.X, self.Y = X-2, Y-2-1
+ self.char = char
+ self.scr.clear()
+
+ # Draw a border around the board
+ border_line='+'+(self.X*'-')+'+'
+ self.scr.addstr(0, 0, border_line)
+ self.scr.addstr(self.Y+1,0, border_line)
+ for y in range(0, self.Y):
+ self.scr.addstr(1+y, 0, '|')
+ self.scr.addstr(1+y, self.X+1, '|')
+ self.scr.refresh()
+
+ def set(self, y, x):
+ """Set a cell to the live state"""
+ if x<0 or self.X<=x or y<0 or self.Y<=y:
+ raise ValueError, "Coordinates out of range %i,%i"% (y,x)
+ self.state[x,y] = 1
+
+ def toggle(self, y, x):
+ """Toggle a cell's state between live and dead"""
+ if x<0 or self.X<=x or y<0 or self.Y<=y:
+ raise ValueError, "Coordinates out of range %i,%i"% (y,x)
+ if self.state.has_key( (x,y) ):
+ del self.state[x,y]
+ self.scr.addch(y+1, x+1, ' ')
+ else:
+ self.state[x,y]=1
+ self.scr.addch(y+1, x+1, self.char)
+ self.scr.refresh()
def erase(self):
- """Clear the entire board and update the board display"""
- self.state={}
- self.display(update_board=0)
+ """Clear the entire board and update the board display"""
+ self.state={}
+ self.display(update_board=0)
def display(self, update_board=1):
- """Display the whole board, optionally computing one generation"""
- M,N = self.X, self.Y
- if not update_board:
- for i in range(0, M):
- for j in range(0, N):
- if self.state.has_key( (i,j) ):
- self.scr.addch(j+1, i+1, self.char)
- else:
- self.scr.addch(j+1, i+1, ' ')
- self.scr.refresh()
- return
-
- d={} ; self.boring=1
- for i in range(0, M):
- L=range( max(0, i-1), min(M, i+2) )
- for j in range(0, N):
- s=0
- live=self.state.has_key( (i,j) )
- for k in range( max(0, j-1), min(N, j+2) ):
- for l in L:
- if self.state.has_key( (l,k) ):
- s=s+1
- s=s-live
- if s==3:
- # Birth
- d[i,j]=1
- self.scr.addch(j+1, i+1, self.char)
- if not live: self.boring=0
- elif s==2 and live: d[i,j]=1 # Survival
- elif live:
- # Death
- self.scr.addch(j+1, i+1, ' ')
- self.boring=0
- self.state=d
- self.scr.refresh()
+ """Display the whole board, optionally computing one generation"""
+ M,N = self.X, self.Y
+ if not update_board:
+ for i in range(0, M):
+ for j in range(0, N):
+ if self.state.has_key( (i,j) ):
+ self.scr.addch(j+1, i+1, self.char)
+ else:
+ self.scr.addch(j+1, i+1, ' ')
+ self.scr.refresh()
+ return
+
+ d={} ; self.boring=1
+ for i in range(0, M):
+ L=range( max(0, i-1), min(M, i+2) )
+ for j in range(0, N):
+ s=0
+ live=self.state.has_key( (i,j) )
+ for k in range( max(0, j-1), min(N, j+2) ):
+ for l in L:
+ if self.state.has_key( (l,k) ):
+ s=s+1
+ s=s-live
+ if s==3:
+ # Birth
+ d[i,j]=1
+ self.scr.addch(j+1, i+1, self.char)
+ if not live: self.boring=0
+ elif s==2 and live: d[i,j]=1 # Survival
+ elif live:
+ # Death
+ self.scr.addch(j+1, i+1, ' ')
+ self.boring=0
+ self.state=d
+ self.scr.refresh()
def makeRandom(self):
- "Fill the board with a random pattern"
- self.state={}
- for i in range(0, self.X):
+ "Fill the board with a random pattern"
+ self.state={}
+ for i in range(0, self.X):
for j in range(0, self.Y):
if random.random() > 0.5: self.set(j,i)
@@ -149,7 +149,7 @@ def main(stdscr):
display_menu(stdscr, menu_y)
# Allocate a subwindow for the Life board and create the board object
- subwin=stdscr.subwin(stdscr_y-3, stdscr_x, 0, 0)
+ subwin=stdscr.subwin(stdscr_y-3, stdscr_x, 0, 0)
board=LifeBoard(subwin, char=ord('*'))
board.display(update_board=0)
@@ -158,66 +158,65 @@ def main(stdscr):
# Main loop:
while (1):
- stdscr.move(1+ypos, 1+xpos) # Move the cursor
- c=stdscr.getch() # Get a keystroke
- if 0<c<256:
- c=chr(c)
- if c in ' \n':
- board.toggle(ypos, xpos)
- elif c in 'Cc':
- erase_menu(stdscr, menu_y)
- stdscr.addstr(menu_y, 6, ' Hit any key to stop continuously '
- 'updating the screen.')
- stdscr.refresh()
- # Activate nodelay mode; getch() will return -1
- # if no keystroke is available, instead of waiting.
- stdscr.nodelay(1)
- while (1):
- c=stdscr.getch()
- if c!=-1: break
- stdscr.addstr(0,0, '/'); stdscr.refresh()
- board.display()
- stdscr.addstr(0,0, '+'); stdscr.refresh()
-
- stdscr.nodelay(0) # Disable nodelay mode
- display_menu(stdscr, menu_y)
-
- elif c in 'Ee': board.erase()
- elif c in 'Qq': break
- elif c in 'Rr':
- board.makeRandom()
- board.display(update_board=0)
- elif c in 'Ss':
- board.display()
- else: pass # Ignore incorrect keys
- elif c==curses.KEY_UP and ypos>0: ypos=ypos-1
- elif c==curses.KEY_DOWN and ypos<board.Y-1: ypos=ypos+1
- elif c==curses.KEY_LEFT and xpos>0: xpos=xpos-1
- elif c==curses.KEY_RIGHT and xpos<board.X-1: xpos=xpos+1
- else: pass # Ignore incorrect keys
+ stdscr.move(1+ypos, 1+xpos) # Move the cursor
+ c=stdscr.getch() # Get a keystroke
+ if 0<c<256:
+ c=chr(c)
+ if c in ' \n':
+ board.toggle(ypos, xpos)
+ elif c in 'Cc':
+ erase_menu(stdscr, menu_y)
+ stdscr.addstr(menu_y, 6, ' Hit any key to stop continuously '
+ 'updating the screen.')
+ stdscr.refresh()
+ # Activate nodelay mode; getch() will return -1
+ # if no keystroke is available, instead of waiting.
+ stdscr.nodelay(1)
+ while (1):
+ c=stdscr.getch()
+ if c!=-1: break
+ stdscr.addstr(0,0, '/'); stdscr.refresh()
+ board.display()
+ stdscr.addstr(0,0, '+'); stdscr.refresh()
+
+ stdscr.nodelay(0) # Disable nodelay mode
+ display_menu(stdscr, menu_y)
+
+ elif c in 'Ee': board.erase()
+ elif c in 'Qq': break
+ elif c in 'Rr':
+ board.makeRandom()
+ board.display(update_board=0)
+ elif c in 'Ss':
+ board.display()
+ else: pass # Ignore incorrect keys
+ elif c==curses.KEY_UP and ypos>0: ypos=ypos-1
+ elif c==curses.KEY_DOWN and ypos<board.Y-1: ypos=ypos+1
+ elif c==curses.KEY_LEFT and xpos>0: xpos=xpos-1
+ elif c==curses.KEY_RIGHT and xpos<board.X-1: xpos=xpos+1
+ else: pass # Ignore incorrect keys
if __name__=='__main__':
try:
- # Initialize curses
- stdscr=curses.initscr()
- # Turn off echoing of keys, and enter cbreak mode,
- # where no buffering is performed on keyboard input
- curses.noecho() ; curses.cbreak()
-
- # In keypad mode, escape sequences for special keys
- # (like the cursor keys) will be interpreted and
- # a special value like curses.KEY_LEFT will be returned
- stdscr.keypad(1)
- main(stdscr) # Enter the main loop
- # Set everything back to normal
- stdscr.keypad(0)
- curses.echo() ; curses.nocbreak()
- curses.endwin() # Terminate curses
+ # Initialize curses
+ stdscr=curses.initscr()
+ # Turn off echoing of keys, and enter cbreak mode,
+ # where no buffering is performed on keyboard input
+ curses.noecho() ; curses.cbreak()
+
+ # In keypad mode, escape sequences for special keys
+ # (like the cursor keys) will be interpreted and
+ # a special value like curses.KEY_LEFT will be returned
+ stdscr.keypad(1)
+ main(stdscr) # Enter the main loop
+ # Set everything back to normal
+ stdscr.keypad(0)
+ curses.echo() ; curses.nocbreak()
+ curses.endwin() # Terminate curses
except:
# In the event of an error, restore the terminal
- # to a sane state.
- stdscr.keypad(0)
- curses.echo() ; curses.nocbreak()
- curses.endwin()
- traceback.print_exc() # Print the exception
-
+ # to a sane state.
+ stdscr.keypad(0)
+ curses.echo() ; curses.nocbreak()
+ curses.endwin()
+ traceback.print_exc() # Print the exception
diff --git a/Demo/curses/ncurses.py b/Demo/curses/ncurses.py
index 96aa142..c9394d0 100644
--- a/Demo/curses/ncurses.py
+++ b/Demo/curses/ncurses.py
@@ -209,7 +209,7 @@ def demo_panels(win):
w5.addstr(mod[itmp])
pflush()
wait_a_while()
-
+
saywhat("m5; press any key to continue")
w4.move(curses.LINES / 6, 1)
w4.addstr(mod[itmp])
@@ -218,7 +218,7 @@ def demo_panels(win):
w5.addstr(mod[itmp])
pflush()
wait_a_while()
-
+
saywhat("m4; press any key to continue")
p4.move(curses.LINES / 6, (itmp + 1) * curses.COLS / 8)
pflush()
diff --git a/Demo/curses/rain.py b/Demo/curses/rain.py
index 2399d7f..69794b3 100644
--- a/Demo/curses/rain.py
+++ b/Demo/curses/rain.py
@@ -27,18 +27,18 @@ def main(win):
# Initialize it globally for convenience.
global stdscr
stdscr = win
-
+
if curses.has_colors():
bg = curses.COLOR_BLACK
curses.init_pair(1, curses.COLOR_BLUE, bg)
curses.init_pair(2, curses.COLOR_CYAN, bg)
-
+
curses.nl()
curses.noecho()
# XXX curs_set() always returns ERR
# curses.curs_set(0)
stdscr.timeout(0)
-
+
c = curses.COLS - 4
r = curses.LINES - 4
xpos = [0] * c
@@ -46,38 +46,38 @@ def main(win):
for j in range(4, -1, -1):
xpos[j] = randrange(0, c) + 2
ypos[j] = randrange(0, r) + 2
-
+
j = 0
while 1:
x = randrange(0, c) + 2
y = randrange(0, r) + 2
-
+
stdscr.addch(y, x, ord('.'))
-
+
stdscr.addch(ypos[j], xpos[j], ord('o'))
-
+
j = next_j(j)
stdscr.addch(ypos[j], xpos[j], ord('O'))
-
+
j = next_j(j)
stdscr.addch( ypos[j] - 1, xpos[j], ord('-'))
stdscr.addstr(ypos[j], xpos[j] - 1, "|.|")
stdscr.addch( ypos[j] + 1, xpos[j], ord('-'))
-
+
j = next_j(j)
stdscr.addch( ypos[j] - 2, xpos[j], ord('-'))
stdscr.addstr(ypos[j] - 1, xpos[j] - 1, "/ \\")
stdscr.addstr(ypos[j], xpos[j] - 2, "| O |")
stdscr.addstr(ypos[j] + 1, xpos[j] - 1, "\\ /")
stdscr.addch( ypos[j] + 2, xpos[j], ord('-'))
-
+
j = next_j(j)
stdscr.addch( ypos[j] - 2, xpos[j], ord(' '))
stdscr.addstr(ypos[j] - 1, xpos[j] - 1, " ")
stdscr.addstr(ypos[j], xpos[j] - 2, " ")
stdscr.addstr(ypos[j] + 1, xpos[j] - 1, " ")
stdscr.addch( ypos[j] + 2, xpos[j], ord(' '))
-
+
xpos[j] = x
ypos[j] = y
@@ -90,5 +90,5 @@ def main(win):
stdscr.nodelay(1)
curses.napms(50)
-
+
curses.wrapper(main)
diff --git a/Demo/curses/tclock.py b/Demo/curses/tclock.py
index f423e9a..1950043 100644
--- a/Demo/curses/tclock.py
+++ b/Demo/curses/tclock.py
@@ -66,7 +66,7 @@ def dline(pair, from_x, from_y, x2, y2, ch):
def main(win):
global stdscr
stdscr = win
-
+
lastbeep = -1
my_bg = curses.COLOR_BLACK
@@ -80,7 +80,7 @@ def main(win):
cx = (curses.COLS - 1) / 2
cy = curses.LINES / 2
- ch = min( cy-1, int(cx / ASPECT) - 1)
+ ch = min( cy-1, int(cx / ASPECT) - 1)
mradius = (3 * ch) / 4
hradius = ch / 2
sradius = 5 * ch / 6
@@ -95,7 +95,7 @@ def main(win):
"ASCII Clock by Howard Jones <ha.jones@ic.ac.uk>, 1994")
sradius = max(sradius-4, 8)
-
+
while 1:
curses.napms(1000)
@@ -125,7 +125,7 @@ def main(win):
stdscr.attrset(curses.color_pair(1))
plot(cx + sdx, cy - sdy, ord('O'))
-
+
if curses.has_colors():
stdscr.attrset(curses.color_pair(0))
diff --git a/Demo/curses/xmas.py b/Demo/curses/xmas.py
index 99c7087..e51bc5f 100644
--- a/Demo/curses/xmas.py
+++ b/Demo/curses/xmas.py
@@ -66,9 +66,9 @@ def seas():
stdscr.addch(14, 1, ord('N'))
stdscr.addch(16, 1, ord("'"))
stdscr.addch(18, 1, ord('S'))
-
+
return
-
+
def greet():
stdscr.addch(3, 5, ord('G'))
stdscr.addch(5, 5, ord('R'))
@@ -300,7 +300,7 @@ def blinkit():
break
treescrn8.touchwin()
-
+
# ALL ON
treescrn.overlay(treescrn8)
treescrn8.refresh()
@@ -347,10 +347,10 @@ def reindeer():
else:
dotdeer0.addch(y_pos, x_pos, ord('*'))
dotdeer0.refresh()
- w_del_msg.refresh()
- dotdeer0.erase()
- dotdeer0.refresh()
- w_del_msg.refresh()
+ w_del_msg.refresh()
+ dotdeer0.erase()
+ dotdeer0.refresh()
+ w_del_msg.refresh()
x_pos = 58
@@ -360,76 +360,76 @@ def reindeer():
w_del_msg.refresh()
for looper in range(0, 4):
- deer_step(lildeer3, y_pos, x_pos)
- deer_step(lildeer2, y_pos, x_pos)
- deer_step(lildeer1, y_pos, x_pos)
- deer_step(lildeer2, y_pos, x_pos)
- deer_step(lildeer3, y_pos, x_pos)
-
- lildeer0.touchwin()
- lildeer0.refresh()
- w_del_msg.refresh()
+ deer_step(lildeer3, y_pos, x_pos)
+ deer_step(lildeer2, y_pos, x_pos)
+ deer_step(lildeer1, y_pos, x_pos)
+ deer_step(lildeer2, y_pos, x_pos)
+ deer_step(lildeer3, y_pos, x_pos)
+
+ lildeer0.touchwin()
+ lildeer0.refresh()
+ w_del_msg.refresh()
- x_pos -= 2
+ x_pos -= 2
x_pos = 35
for y_pos in range(5, 10):
- middeer0.touchwin()
- middeer0.refresh()
- w_del_msg.refresh()
+ middeer0.touchwin()
+ middeer0.refresh()
+ w_del_msg.refresh()
for looper in range(0, 2):
- deer_step(middeer3, y_pos, x_pos)
- deer_step(middeer2, y_pos, x_pos)
- deer_step(middeer1, y_pos, x_pos)
- deer_step(middeer2, y_pos, x_pos)
- deer_step(middeer3, y_pos, x_pos)
-
- middeer0.touchwin()
- middeer0.refresh()
- w_del_msg.refresh()
+ deer_step(middeer3, y_pos, x_pos)
+ deer_step(middeer2, y_pos, x_pos)
+ deer_step(middeer1, y_pos, x_pos)
+ deer_step(middeer2, y_pos, x_pos)
+ deer_step(middeer3, y_pos, x_pos)
+
+ middeer0.touchwin()
+ middeer0.refresh()
+ w_del_msg.refresh()
- x_pos -= 3
+ x_pos -= 3
look_out(300)
y_pos = 1
for x_pos in range(8, 16):
- deer_step(bigdeer4, y_pos, x_pos)
- deer_step(bigdeer3, y_pos, x_pos)
- deer_step(bigdeer2, y_pos, x_pos)
- deer_step(bigdeer1, y_pos, x_pos)
- deer_step(bigdeer2, y_pos, x_pos)
- deer_step(bigdeer3, y_pos, x_pos)
- deer_step(bigdeer4, y_pos, x_pos)
- deer_step(bigdeer0, y_pos, x_pos)
+ deer_step(bigdeer4, y_pos, x_pos)
+ deer_step(bigdeer3, y_pos, x_pos)
+ deer_step(bigdeer2, y_pos, x_pos)
+ deer_step(bigdeer1, y_pos, x_pos)
+ deer_step(bigdeer2, y_pos, x_pos)
+ deer_step(bigdeer3, y_pos, x_pos)
+ deer_step(bigdeer4, y_pos, x_pos)
+ deer_step(bigdeer0, y_pos, x_pos)
x_pos -= 1
for looper in range(0, 6):
- deer_step(lookdeer4, y_pos, x_pos)
- deer_step(lookdeer3, y_pos, x_pos)
- deer_step(lookdeer2, y_pos, x_pos)
- deer_step(lookdeer1, y_pos, x_pos)
- deer_step(lookdeer2, y_pos, x_pos)
- deer_step(lookdeer3, y_pos, x_pos)
- deer_step(lookdeer4, y_pos, x_pos)
+ deer_step(lookdeer4, y_pos, x_pos)
+ deer_step(lookdeer3, y_pos, x_pos)
+ deer_step(lookdeer2, y_pos, x_pos)
+ deer_step(lookdeer1, y_pos, x_pos)
+ deer_step(lookdeer2, y_pos, x_pos)
+ deer_step(lookdeer3, y_pos, x_pos)
+ deer_step(lookdeer4, y_pos, x_pos)
deer_step(lookdeer0, y_pos, x_pos)
for y_pos in range(y_pos, 10):
for looper in range(0, 2):
- deer_step(bigdeer4, y_pos, x_pos)
- deer_step(bigdeer3, y_pos, x_pos)
- deer_step(bigdeer2, y_pos, x_pos)
- deer_step(bigdeer1, y_pos, x_pos)
- deer_step(bigdeer2, y_pos, x_pos)
- deer_step(bigdeer3, y_pos, x_pos)
- deer_step(bigdeer4, y_pos, x_pos)
- deer_step(bigdeer0, y_pos, x_pos)
+ deer_step(bigdeer4, y_pos, x_pos)
+ deer_step(bigdeer3, y_pos, x_pos)
+ deer_step(bigdeer2, y_pos, x_pos)
+ deer_step(bigdeer1, y_pos, x_pos)
+ deer_step(bigdeer2, y_pos, x_pos)
+ deer_step(bigdeer3, y_pos, x_pos)
+ deer_step(bigdeer4, y_pos, x_pos)
+ deer_step(bigdeer0, y_pos, x_pos)
y_pos -= 1
@@ -439,7 +439,7 @@ def reindeer():
def main(win):
global stdscr
stdscr = win
-
+
global my_bg, y_pos, x_pos
global treescrn, treescrn2, treescrn3, treescrn4
global treescrn5, treescrn6, treescrn7, treescrn8
@@ -452,7 +452,7 @@ def main(win):
my_bg = curses.COLOR_BLACK
# curses.curs_set(0)
-
+
treescrn = curses.newwin(16, 27, 3, 53)
treescrn2 = curses.newwin(16, 27, 3, 53)
treescrn3 = curses.newwin(16, 27, 3, 53)
@@ -461,37 +461,37 @@ def main(win):
treescrn6 = curses.newwin(16, 27, 3, 53)
treescrn7 = curses.newwin(16, 27, 3, 53)
treescrn8 = curses.newwin(16, 27, 3, 53)
-
+
dotdeer0 = curses.newwin(3, 71, 0, 8)
-
+
stardeer0 = curses.newwin(4, 56, 0, 8)
-
+
lildeer0 = curses.newwin(7, 53, 0, 8)
lildeer1 = curses.newwin(2, 4, 0, 0)
lildeer2 = curses.newwin(2, 4, 0, 0)
lildeer3 = curses.newwin(2, 4, 0, 0)
-
+
middeer0 = curses.newwin(15, 42, 0, 8)
middeer1 = curses.newwin(3, 7, 0, 0)
middeer2 = curses.newwin(3, 7, 0, 0)
middeer3 = curses.newwin(3, 7, 0, 0)
-
+
bigdeer0 = curses.newwin(10, 23, 0, 0)
bigdeer1 = curses.newwin(10, 23, 0, 0)
bigdeer2 = curses.newwin(10, 23, 0, 0)
bigdeer3 = curses.newwin(10, 23, 0, 0)
bigdeer4 = curses.newwin(10, 23, 0, 0)
-
+
lookdeer0 = curses.newwin(10, 25, 0, 0)
lookdeer1 = curses.newwin(10, 25, 0, 0)
lookdeer2 = curses.newwin(10, 25, 0, 0)
lookdeer3 = curses.newwin(10, 25, 0, 0)
lookdeer4 = curses.newwin(10, 25, 0, 0)
-
+
w_holiday = curses.newwin(1, 27, 3, 27)
-
+
w_del_msg = curses.newwin(1, 20, 23, 60)
-
+
try:
w_del_msg.addstr(0, 0, "Hit any key to quit")
except curses.error:
@@ -501,7 +501,7 @@ def main(win):
w_holiday.addstr(0, 0, "H A P P Y H O L I D A Y S")
except curses.error:
pass
-
+
# set up the windows for our various reindeer
lildeer1.addch(0, 0, ord('V'))
lildeer1.addch(1, 0, ord('@'))
@@ -511,7 +511,7 @@ def main(win):
lildeer1.addch(1, 3, ord('~'))
except curses.error:
pass
-
+
lildeer2.addch(0, 0, ord('V'))
lildeer2.addch(1, 0, ord('@'))
lildeer2.addch(1, 1, ord('|'))
@@ -520,16 +520,16 @@ def main(win):
lildeer2.addch(1, 3, ord('~'))
except curses.error:
pass
-
+
lildeer3.addch(0, 0, ord('V'))
lildeer3.addch(1, 0, ord('@'))
lildeer3.addch(1, 1, ord('>'))
lildeer3.addch(1, 2, ord('<'))
try:
- lildeer2.addch(1, 3, ord('~')) # XXX
+ lildeer2.addch(1, 3, ord('~')) # XXX
except curses.error:
pass
-
+
middeer1.addch(0, 2, ord('y'))
middeer1.addch(0, 3, ord('y'))
middeer1.addch(1, 2, ord('0'))
@@ -539,7 +539,7 @@ def main(win):
middeer1.addch(1, 6, ord('~'))
middeer1.addch(2, 3, ord('\\'))
middeer1.addch(2, 5, ord('/'))
-
+
middeer2.addch(0, 2, ord('y'))
middeer2.addch(0, 3, ord('y'))
middeer2.addch(1, 2, ord('0'))
@@ -549,7 +549,7 @@ def main(win):
middeer2.addch(1, 6, ord('~'))
middeer2.addch(2, 3, ord('|'))
middeer2.addch(2, 5, ord('|'))
-
+
middeer3.addch(0, 2, ord('y'))
middeer3.addch(0, 3, ord('y'))
middeer3.addch(1, 2, ord('0'))
@@ -577,11 +577,11 @@ def main(win):
bigdeer1.addch(4, 19, ord('\\'))
bigdeer1.addch(4, 22, ord('\\'))
bigdeer1.addstr(5, 7, "^~~~~~~~~// ~~U")
- bigdeer1.addstr(6, 7, "( \\_____( /") # ))
+ bigdeer1.addstr(6, 7, "( \\_____( /") # ))
bigdeer1.addstr(7, 8, "( ) /")
bigdeer1.addstr(8, 9, "\\\\ /")
bigdeer1.addstr(9, 11, "\\>/>")
-
+
bigdeer2.addch(0, 17, ord('\\'))
bigdeer2.addch(0, 18, ord('/'))
bigdeer2.addch(0, 19, ord('\\'))
@@ -599,11 +599,11 @@ def main(win):
bigdeer2.addch(4, 19, ord('\\'))
bigdeer2.addch(4, 22, ord('\\'))
bigdeer2.addstr(5, 7, "^~~~~~~~~// ~~U")
- bigdeer2.addstr(6, 7, "(( )____( /") # ))
+ bigdeer2.addstr(6, 7, "(( )____( /") # ))
bigdeer2.addstr(7, 7, "( / |")
bigdeer2.addstr(8, 8, "\\/ |")
bigdeer2.addstr(9, 9, "|> |>")
-
+
bigdeer3.addch(0, 17, ord('\\'))
bigdeer3.addch(0, 18, ord('/'))
bigdeer3.addch(0, 19, ord('\\'))
@@ -621,11 +621,11 @@ def main(win):
bigdeer3.addch(4, 19, ord('\\'))
bigdeer3.addch(4, 22, ord('\\'))
bigdeer3.addstr(5, 7, "^~~~~~~~~// ~~U")
- bigdeer3.addstr(6, 6, "( ()_____( /") # ))
+ bigdeer3.addstr(6, 6, "( ()_____( /") # ))
bigdeer3.addstr(7, 6, "/ / /")
bigdeer3.addstr(8, 5, "|/ \\")
bigdeer3.addstr(9, 5, "/> \\>")
-
+
bigdeer4.addch(0, 17, ord('\\'))
bigdeer4.addch(0, 18, ord('/'))
bigdeer4.addch(0, 19, ord('\\'))
@@ -643,51 +643,51 @@ def main(win):
bigdeer4.addch(4, 19, ord('\\'))
bigdeer4.addch(4, 22, ord('\\'))
bigdeer4.addstr(5, 7, "^~~~~~~~~// ~~U")
- bigdeer4.addstr(6, 6, "( )______( /") # )
- bigdeer4.addstr(7, 5, "(/ \\") # )
+ bigdeer4.addstr(6, 6, "( )______( /") # )
+ bigdeer4.addstr(7, 5, "(/ \\") # )
bigdeer4.addstr(8, 0, "v___= ----^")
-
+
lookdeer1.addstr(0, 16, "\\/ \\/")
lookdeer1.addstr(1, 17, "\\Y/ \\Y/")
lookdeer1.addstr(2, 19, "\\=/")
lookdeer1.addstr(3, 17, "^\\o o/^")
lookdeer1.addstr(4, 17, "//( )")
lookdeer1.addstr(5, 7, "^~~~~~~~~// \\O/")
- lookdeer1.addstr(6, 7, "( \\_____( /") # ))
+ lookdeer1.addstr(6, 7, "( \\_____( /") # ))
lookdeer1.addstr(7, 8, "( ) /")
lookdeer1.addstr(8, 9, "\\\\ /")
lookdeer1.addstr(9, 11, "\\>/>")
-
+
lookdeer2.addstr(0, 16, "\\/ \\/")
lookdeer2.addstr(1, 17, "\\Y/ \\Y/")
lookdeer2.addstr(2, 19, "\\=/")
lookdeer2.addstr(3, 17, "^\\o o/^")
lookdeer2.addstr(4, 17, "//( )")
lookdeer2.addstr(5, 7, "^~~~~~~~~// \\O/")
- lookdeer2.addstr(6, 7, "(( )____( /") # ))
+ lookdeer2.addstr(6, 7, "(( )____( /") # ))
lookdeer2.addstr(7, 7, "( / |")
lookdeer2.addstr(8, 8, "\\/ |")
lookdeer2.addstr(9, 9, "|> |>")
-
+
lookdeer3.addstr(0, 16, "\\/ \\/")
lookdeer3.addstr(1, 17, "\\Y/ \\Y/")
lookdeer3.addstr(2, 19, "\\=/")
lookdeer3.addstr(3, 17, "^\\o o/^")
lookdeer3.addstr(4, 17, "//( )")
lookdeer3.addstr(5, 7, "^~~~~~~~~// \\O/")
- lookdeer3.addstr(6, 6, "( ()_____( /") # ))
+ lookdeer3.addstr(6, 6, "( ()_____( /") # ))
lookdeer3.addstr(7, 6, "/ / /")
lookdeer3.addstr(8, 5, "|/ \\")
lookdeer3.addstr(9, 5, "/> \\>")
-
+
lookdeer4.addstr(0, 16, "\\/ \\/")
lookdeer4.addstr(1, 17, "\\Y/ \\Y/")
lookdeer4.addstr(2, 19, "\\=/")
lookdeer4.addstr(3, 17, "^\\o o/^")
lookdeer4.addstr(4, 17, "//( )")
lookdeer4.addstr(5, 7, "^~~~~~~~~// \\O/")
- lookdeer4.addstr(6, 6, "( )______( /") # )
- lookdeer4.addstr(7, 5, "(/ \\") # )
+ lookdeer4.addstr(6, 6, "( )______( /") # )
+ lookdeer4.addstr(7, 5, "(/ \\") # )
lookdeer4.addstr(8, 0, "v___= ----^")
###############################################
@@ -780,9 +780,9 @@ def main(win):
# strng1
treescrn4.addch(3, 13, ord(' '))
-
+
# strng2
-
+
# strng3
treescrn4.addch(7, 15, ord(' '))
treescrn4.addch(8, 11, ord(' '))
@@ -830,67 +830,67 @@ def main(win):
treescrn.overlay(treescrn6)
# balls
- treescrn6.addch(6, 7, ord(' '))
- treescrn6.addch(7, 18, ord(' '))
- treescrn6.addch(10, 4, ord(' '))
- treescrn6.addch(11, 23, ord(' '))
+ treescrn6.addch(6, 7, ord(' '))
+ treescrn6.addch(7, 18, ord(' '))
+ treescrn6.addch(10, 4, ord(' '))
+ treescrn6.addch(11, 23, ord(' '))
- # star
- treescrn6.standout()
- treescrn6.addch(0, 12, ord('*'))
- treescrn6.standend()
+ # star
+ treescrn6.standout()
+ treescrn6.addch(0, 12, ord('*'))
+ treescrn6.standend()
- # strng1
+ # strng1
- # strng2
- treescrn6.addch(5, 11, ord(' '))
+ # strng2
+ treescrn6.addch(5, 11, ord(' '))
- # strng3
- treescrn6.addch(7, 13, ord(' '))
- treescrn6.addch(8, 9, ord(' '))
+ # strng3
+ treescrn6.addch(7, 13, ord(' '))
+ treescrn6.addch(8, 9, ord(' '))
- # strng4
- treescrn6.addch(9, 14, ord(' '))
- treescrn6.addch(10, 10, ord(' '))
- treescrn6.addch(11, 6, ord(' '))
+ # strng4
+ treescrn6.addch(9, 14, ord(' '))
+ treescrn6.addch(10, 10, ord(' '))
+ treescrn6.addch(11, 6, ord(' '))
- # strng5
- treescrn6.addch(11, 16, ord(' '))
- treescrn6.addch(12, 12, ord(' '))
+ # strng5
+ treescrn6.addch(11, 16, ord(' '))
+ treescrn6.addch(12, 12, ord(' '))
- # treescrn7
+ # treescrn7
- treescrn.overlay(treescrn7)
+ treescrn.overlay(treescrn7)
- # balls
- treescrn7.addch(3, 15, ord(' '))
- treescrn7.addch(6, 7, ord(' '))
- treescrn7.addch(7, 18, ord(' '))
- treescrn7.addch(10, 4, ord(' '))
- treescrn7.addch(11, 22, ord(' '))
+ # balls
+ treescrn7.addch(3, 15, ord(' '))
+ treescrn7.addch(6, 7, ord(' '))
+ treescrn7.addch(7, 18, ord(' '))
+ treescrn7.addch(10, 4, ord(' '))
+ treescrn7.addch(11, 22, ord(' '))
- # star
- treescrn7.addch(0, 12, ord('*'))
+ # star
+ treescrn7.addch(0, 12, ord('*'))
- # strng1
- treescrn7.addch(3, 12, ord(' '))
+ # strng1
+ treescrn7.addch(3, 12, ord(' '))
- # strng2
- treescrn7.addch(5, 13, ord(' '))
- treescrn7.addch(6, 9, ord(' '))
+ # strng2
+ treescrn7.addch(5, 13, ord(' '))
+ treescrn7.addch(6, 9, ord(' '))
- # strng3
- treescrn7.addch(7, 15, ord(' '))
- treescrn7.addch(8, 11, ord(' '))
+ # strng3
+ treescrn7.addch(7, 15, ord(' '))
+ treescrn7.addch(8, 11, ord(' '))
- # strng4
- treescrn7.addch(9, 16, ord(' '))
- treescrn7.addch(10, 12, ord(' '))
- treescrn7.addch(11, 8, ord(' '))
+ # strng4
+ treescrn7.addch(9, 16, ord(' '))
+ treescrn7.addch(10, 12, ord(' '))
+ treescrn7.addch(11, 8, ord(' '))
- # strng5
- treescrn7.addch(11, 18, ord(' '))
- treescrn7.addch(12, 14, ord(' '))
+ # strng5
+ treescrn7.addch(11, 18, ord(' '))
+ treescrn7.addch(12, 14, ord(' '))
look_out(150)
reindeer()
@@ -902,5 +902,5 @@ def main(win):
look_out(500)
for i in range(0, 20):
blinkit()
-
+
curses.wrapper(main)