summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 10:37:25 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 10:37:25 (GMT)
commita6eab3e7ffcd9f6530c54931bbba3e0f108e0dd3 (patch)
tree81b9816302fa403d8ffd4fbb5399a811612f7ef5 /wasp
parented242b84a6e70aff344669559c038348c822413a (diff)
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>
Diffstat (limited to 'wasp')
-rw-r--r--wasp/apps/software.py3
-rw-r--r--wasp/wasp.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/wasp/apps/software.py b/wasp/apps/software.py
index 2c7869c..a39cce0 100644
--- a/wasp/apps/software.py
+++ b/wasp/apps/software.py
@@ -63,8 +63,7 @@ class SoftwareApp():
if checkbox.touch(event):
label = checkbox.label.replace(' ', '')
if checkbox.state:
- exec('import apps.{}'.format(module))
- exec('wasp.system.register(apps.{}.{}App())'.format(module, label))
+ wasp.system.register('apps.{}.{}App'.format(module, label))
else:
for app in wasp.system.launcher_ring:
if type(app).__name__.startswith(label):
diff --git a/wasp/wasp.py b/wasp/wasp.py
index 79f706c..c9f40db 100644
--- a/wasp/wasp.py
+++ b/wasp/wasp.py
@@ -164,6 +164,10 @@ class Manager():
:param object app: The application to regsister
"""
+ if isinstance(app, str):
+ exec('import ' + app[:app.rindex('.')])
+ app = eval(app + '()')
+
if quick_ring == True:
self.quick_ring.append(app)
else: