def move_right(): y,x = curses.getyx() curses.move(y,x+1)
def move_page_end(): y,x = scr.getmaxyx() curses.move(y,x)
def move_left(): y,x = curses.getyx() curses.move(y,x-1)
def move_page_home(): curses.move(0,0)
def move_down(): y,x = curses.getyx() curses.move(y+1,x)
def move_up(): y,x = curses.getyx() curses.move(y-1,x)
curses.move(y,x+1) # Demonstrate how to move the cursor up one line (without affecting its horizontal position) def move_up(): y,x = curses.getyx() curses.move(y-1,x) # Demonstrate how to move the cursor down one line (without affecting its horizontal position) def move_down(): y,x = curses.getyx() curses.move(y+1,x) # Demonstrate how to move the cursor to the beginning of the line def move_line_home() y,x = curses.getyx() curses.move(y,0) # Demonstrate how to move the cursor to the end of the line def move_line_end() y,x = curses.getyx() maxy,maxx = scr.getmaxyx() curses.move(y,maxx) # Demonstrate how to move the cursor to the top left corner of the screen def move_page_home(): curses.move(0,0) # Demonstrate how to move the cursor to the bottom right corner of the screen def move_page_end(): y,x = scr.getmaxyx() curses.move(y,x)
#!/usr/bin/env python3 from curses import initscr, endwin, getch, noecho, printw, move, echo from curses import curs_set, attron, attroff, A_BOLD # Initialize curses mode initscr() # Disable echoing of characters read from keyboard noecho() # Draw the fancy box move(0, 0) # Go to left top corner printw('+----------------+') # Print the string move(1, 0) # Go to left side of next line printw('| Input a ') # Print part of string attron(A_BOLD) # Enable bold printw('digit') # Print 'digit' as bold attroff(A_BOLD) # Disable bold printw(': |') move(2, 0) printw('| >>> |') move(3, 0) printw('+----------------+') # Disable cursor curs_set(0) # Read character digit = getch()