• @JonB , ok this is another refinement. To make it more generic, as well as receiving events can also raise our own events via the same mechanism. It's sort of ok, but I know it lacks some finesse.
    I know it's not great, but I feel it's getting there...
    If anyone has some ideas about how to improve this idea, love to hear about it.

    ''' Pythonista Forum - @Phuket2 ''' import ui def raise_event(sender, event_handler = None, **kwargs): sv=sender.superview if not event_handler: if not hasattr(sender, 'event_handler'): return else: event_handler = sender.event_handler handler = event_handler # walk up view chain to find callable action_name while sv: a=getattr(sv, handler, None) if callable(a): stop = a(sender, **kwargs) if stop: return sv=sv.superview return class BClass(ui.View): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.make_view() def make_view(self): btn = ui.Button(frame = (20, 20, 100, 32 )) btn.title = 'Next' btn.action = raise_event btn.event_handler = 'do_next' btn.border_width = .5 self.add_subview(btn) btn = ui.Button(frame = (20, 80, 100, 32 )) btn.title = 'Prev' btn.action = raise_event btn.event_handler = 'do_prev' btn.border_width = .5 self.add_subview(btn) # do_next is also defined in the parent class def do_next(self, sender = None): print('BClass:do_next') #return True def change_btn_name(self, sender, **kwargs): sender.title = kwargs.get('title', '') class MyClass(ui.View): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.view_b = BClass(frame = self.bounds) self.add_subview(self.view_b) def do_next(self, sender = None): print('MyClass:do_next') def do_prev(self, sender = None): print('MyClass:do_prev') raise_event(sender,'change_btn_name', title = 'WOW') if __name__ == '__main__': w, h = 320, 320 f = (0, 0, w, h) mc = MyClass(frame=f, bg_color='white') mc.present('sheet', animated=False)
  • @omz , just when you thought I couldn't be anymore annoying 😁
    Sorry one thing more to mention.
    I think it would be nice if in the site-packages directory, you had another directory called something like 'App Files' or 'Config' or something like that. And then by convention apps that are saving config info , create a directory inside your special folder and store their app specific config info inside their folder.

    Just as a convention, they don't have to of course

Internal error.

Oops! Looks like something went wrong!