default value handling added
This commit is contained in:
parent
fa26893496
commit
c9d7f78f6d
14
__init__.py
14
__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
|
||||
|
Loading…
x
Reference in New Issue
Block a user