BV1AL 之無所不記

2007-09-12

練習python的小程式

#用來練習curses
import time, curses

def draw(line,col):
try:
stdscr.addch(line,col,"H")
stdscr.refresh()
time.sleep(0.02)
except curses.error: pass

while True:
stdscr = curses.initscr()
winH,winW=stdscr.getmaxyx()
stdscr.bkgd('.')
for Y in range (0,winH/2):
for col in range (Y,winW-Y):
draw(Y,col)
for line in range (Y+1,winH-Y):
draw(line,winW-(Y+1))
for col in range (winW-(Y+1),Y-1,-1):
draw(winH-(Y+1),col)
for line in range (winH-(Y+1),Y,-1):
draw(line,Y)
stdscr.clear()
curses.endwin()
如果在 text console下是正常的,但若是在 gnome-terminal
卻會在左下角出現一個"." 而不是"H" !?

0 Comments:

張貼留言

<< Home