August 2018
Intermediate to advanced
366 pages
10h 14m
English
For this recipe, perform the following steps:
import curses
import textwrap
import itertools
class MessageBox(object):
@classmethod
def show(cls, message, cancel=False, width=40):
"""Show a message with an Ok/Cancel dialog.
Provide ``cancel=True`` argument to show a cancel button too. Returns the user selected choice: - 0 = Ok - 1 = Cancel """ dialog = MessageBox(message, width, cancel) return curses.wrapper(dialog._show) def __init__(self, message, width, cancel): self._message = self._build_message(width, message) self._width = width ...