# along with this program. If not, see <http://www.gnu.org/licenses/>.
# -*- mode: python; encoding: utf-8; -*-
-class BaseForm():
- def __init__(self):
- self.type = "none"
- self.name = "Entry"
- def get_type(self):
- return self.type
- def get_name(self):
- return self.name
-
-class StringForm(BaseForm):
- def __init__(self, name, value):
- self.type = "string"
- self.name = name
- if value == None:
- value = ""
- self.value = value
- def get_value(self):
- return self.value
- def set_value(self, value):
- self.value = value
-
-class OptionsForm(BaseForm):
- def __init__(self, name, options, value):
- self.type = "options"
- self.name = name
- self.options = options
- self.value = value
- self.index = self.find_index()
- def find_index(self):
- return map(lambda x: x[0], self.options).index(self.value)
- def get_length(self):
- return len(self.options)
- def get_display(self, index):
- return self.options[index][1]
- def get_value(self, index):
- return self.options[index][0]
- def get_cur_display(self):
- return self.options[self.index][1]
- def get_cur_value(self):
- return self.value
- def get_index(self):
- return self.index
- def set_value(self, value):
- self.value = value
- self.index = self.find_index()
-
class BaseUI():
def get_string(self, prompt=""):
return raw_input(prompt.encode("utf-8"))