tests/curses_unicode.py
author Radek Brich <radek.brich@devl.cz>
Sun, 15 Feb 2015 12:48:23 +0100
changeset 114 26c02bd94bd9
parent 110 cf3d49cdd6e2
permissions -rwxr-xr-x
Add Widget.posreq. Add OffsetLayout.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
110
cf3d49cdd6e2 Add cursesw driver, using curses get_wch() for unicode input. It alse has enabled keypad() to let curses interpret control keys and mouse input.
Radek Brich <radek.brich@devl.cz>
parents: 20
diff changeset
     1
#!/usr/bin/python3
19
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
import curses
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
import locale
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
locale.setlocale(locale.LC_ALL, "")
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
def doStuff(stdscr):
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
  message = "Žlutý kůň.\nPress 'q' to quit.\n"
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
  stdscr.addstr(0, 0, message, 0)
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
  while True:
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
    c = stdscr.getch() # pauses until a key's hit
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
    if c == ord('q'):
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
      break
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
    stdscr.addch(c)
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
5e78d52ebb24 Update demos and tests.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
curses.wrapper(doStuff)