August 2018
Intermediate to advanced
366 pages
10h 14m
English
For this recipe, perform the following steps:
import curses
from curses.textpad import Textbox, rectangle
class TextInput(object):
@classmethod
def show(cls, message, content=None):
return curses.wrapper(cls(message, content)._show)
def __init__(self, message, content):
self._message = message
self._content = content
def _show(self, stdscr):
# Set a reasonable size for our input box.
lines, cols = curses.LINES - 10, curses.COLS - 40
y_begin, x_begin = (curses.LINES - lines) // 2, (curses.COLS - cols) ...