@AddledBadger , not to upset the apple cart so to speak. But another way is to add your own custom attrs to the ui.Button once you have created them. In the below, I added an attr to the ui.Button called your 'username'. It's done just by making the assignment. In this case I assigned a string, but I could have assigned anything. A dict, list, int etc... look, I am still a newbie. I think this way is not considered the best way of doing things. But sometimes you do want to associate data with a ui element. For data I want to associate with an item, I normally use the attr name tag rather than dreaming up new names all the time to help keep it clear.
Anyway it's just another idea.
def __init__(self, *args, **kwargs):
A = ui.Button(title='A', action=self.show_view)
A.AddledBadger = 'This is my A type personality' # adding a attr to the btn at runtime
B = ui.Button(title='B', action=self.show_view)
B.x = A.width + 30
B.AddledBadger = 'This is my B type personality'
# you will notice your attr is print
def show_view(self, sender):
# if not all objects passed to this func may not have your new attr
# you could do something like the below -
if hasattr(sender, 'AddledBadger'):
print('it has my custom attr')
print('sender does not have my custom attr, i better do something else')
if __name__ == '__main__':
f = (0, 0, 300, 400)
v = MyClass(frame = f)