Please don't flame me about this post :) I have just learnt enough about decorators to be dangerous.
I have put a very silly example here of using a decorator to help to debug, but using dialogs. In this case a list dialog. It's super simple, it's more the idea of it. With introspection and more complex ui.View it seems like you could make some pretty cool debug tools rather than just printing to the console all the time.
Maybe I have had too many whiskeys again, however I must admit I haven't had that many yet :).
I would be interested just hearing people's comments, even the super bad ones :). But ok, it's food for thought.
import ui
from functools import wraps
import dialogs
def debug_ui(func):
@wraps(func)
def wrapper(*args, **kwargs):
lst = sorted([d for d in vars(func).keys()])
result = dialogs.list_dialog(title=func.__qualname__, items=lst)
return func(*args, **kwargs)
return wrapper
@debug_ui
def make_button(*args, **kwargs):
pass
@debug_ui
class MyClass(ui.View):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.tb = None
self.make_view()
def make_view(self):
make_button()
pass
def __repr__(self):
return('Stupid Test Class')
if __name__ == '__main__':
f = (0, 0, 300, 400)
v = MyClass(frame = f)
v.present(style='sheet', animated=False)