diff --git a/__init__.py b/__init__.py index 06b6634..abeac19 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,5 @@ import bottombar as bb +import os import readchar import string @@ -34,13 +35,17 @@ class BottomBar(object): self.__bb_args__['__info__'] = (args, kwargs) def add_entry(self, name, f_key, function, *args, **kwargs): + try: + default = kwargs.pop('default') + except KeyError: + default = None if len(args) == 0: args = ("", ) # store data for entry if function in [self.FUNC_BOOL]: - self.__bb_data__[name] = False + self.__bb_data__[name] = default or False elif function in [self.FUNC_TEXT]: - self.__bb_data__[name] = "" + self.__bb_data__[name] = default or "" elif function in [self.FUNC_INFO]: self.__bb_data__[name] = kwargs.pop('infotext') # store function and name for key @@ -100,3 +105,8 @@ class BottomBar(object): self.edit_active = name elif DEBUG: print("unused keystroke in run method:", repr(data)) + else: + if data in ['c', ]: + os.system('clear') + elif data in ['q', ]: + break