#!/usr/bin/python2 # # Copyright (C) 2015 vmware inc. # # Author: Mahmoud Bassiouny import curses from window import Window from readtext import ReadText class WindowStringReader(object): def __init__(self, maxy, maxx, height, width, field, confirmation_err_msg, echo_char, accepted_chars, validation_fn, conversion_fn, title, display_string, inputy, install_config, default_string = None): self.title = title self.display_string = display_string self.install_config = install_config self.inputy = inputy self.width = width self.height = height self.maxx = maxx self.maxy = maxy self.startx = (self.maxx - self.width) / 2 self.starty = (self.maxy - self.height) / 2 self.window = Window(self.height, self.width, self.maxy, self.maxx, self.title, True) self.read_text = ReadText(maxy, maxx, self.window.content_window(), self.inputy, install_config, field, confirmation_err_msg, echo_char, accepted_chars, validation_fn, conversion_fn, default_string) self.window.set_action_panel(self.read_text) self.window.addstr(0, 0, self.display_string) def get_user_string(self, params): return self.window.do_action()