私は初めて呪いを学んでいますが、常に再コンパイルするよりも簡単なので、Pythonでそれを行うことにしました。しかし、私は問題を抱えています。seccondウィンドウを更新しようとすると、出力が得られません。コードスニペットは次のとおりです。
import curses
win = curses.initscr()
curses.noecho()
curses.cbreak()
curses.curs_set(0)
field = curses.newwin(1, 20, 1, 1)
field.addstr(0, 0, "Hello, world!", curses.A_REVERSE)
field.refresh()
initscr()で初期化された通常のwinウィンドウは機能しますが、フィールドウィンドウは表示されません。何か助けはありますか?
編集:これが新しい改訂されたコードですが、まだ機能しません。
import curses
ex = None
def main(stdscr):
global ex
try:
curses.curs_set(0)
except Exception, e:
ex = e
field = curses.newwin(25, 25, 6, 6)
field.border()
cont = True
x, y = 0, 0
while cont:
stdscr.clear()
field.clear()
coords = "%d, %d" % (x, y)
stdscr.addstr(5, 5, coords, curses.A_REVERSE)
field.addstr(y+2, x+2, "@", curses.A_BOLD)
chr = stdscr.getkey()
if chr == 'h':
if x > 0: x -= 1
if chr == 'l':
if x < 20: x += 1
if chr == 'j':
if y > 0: y -= 1
if chr == 'k':
if y < 20: y += 1
if chr == 'q':
cont = False
stdscr.clear()
field.clear()
stdscr.noutrefresh()
field.noutrefresh()
curses.doupdate()
curses.wrapper(main)
if ex is not None:
print 'got %s (%s)' % (type(ex).__name__, ex)