1
0
Fork 0

system: Allows apps to be registered using strings

Use instance tests to identify strings and substitute then for an
instanciated class.

Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
Daniel Thompson 2021-01-10 10:37:25 +00:00
parent ed242b84a6
commit a6eab3e7ff
2 changed files with 5 additions and 2 deletions

View file

@ -63,8 +63,7 @@ class SoftwareApp():
if checkbox.touch(event): if checkbox.touch(event):
label = checkbox.label.replace(' ', '') label = checkbox.label.replace(' ', '')
if checkbox.state: if checkbox.state:
exec('import apps.{}'.format(module)) wasp.system.register('apps.{}.{}App'.format(module, label))
exec('wasp.system.register(apps.{}.{}App())'.format(module, label))
else: else:
for app in wasp.system.launcher_ring: for app in wasp.system.launcher_ring:
if type(app).__name__.startswith(label): if type(app).__name__.startswith(label):

View file

@ -164,6 +164,10 @@ class Manager():
:param object app: The application to regsister :param object app: The application to regsister
""" """
if isinstance(app, str):
exec('import ' + app[:app.rindex('.')])
app = eval(app + '()')
if quick_ring == True: if quick_ring == True:
self.quick_ring.append(app) self.quick_ring.append(app)
else: else: