Ui control subclassing [really good idea 😬]
-
Well made its a crap idea, but t I don't think so...
@omz , we know it's not possible to sub class ui.Button etc. hmmm, maybe objc... Does something... I am not there yet with objc_utils.
But I have seen many work arounds posted in the forum about this. And I am sure they are workable and great. But I think the reason it hasn't taken off is because you really feel like you are going against the grain. Meaning it's not natural for Pythonista.But if you were to make some stubs/base class or something in ui.py so for example we could inherit from a class called ui.ButtonExt, ui.TextViewExt etc...
It's not as much about the complexity of the code, but that we are in the Wild West. If you roll your own, everytime you post something or share something, that needs to be around. But if it's in ui.py, we can sort of subclass the ui. Elements without any distribution issues.
I think it's an important distinction. just because we can do it (we the users) does not necessarily mean we want to do it or think we should do it.
Unfortunately, this puts more on you. It's not my desire, but your std Libs are very important.Back to inheriting from a Python class in ui.py. I am not sure how much work it is. But in my mind, not a lot. The main thing is that we can extend the classes in a way that just works in Pythonista, without inventing our own thing. No need for you to add any functionality (well you could iterate though kwargs and set the attrs 😳) You could also reserve some methods attrs etc... That you might implement later.
I haven't tried to give any code examples. I am not good enough. But I am sure it would be evident to you how to do this.
Just saying 😎
-
@JonB , have made some headway... Not much to brag about though... I can still see the potential 😱😁
I put it in a gist , nowhere close to being finished. But the idea is there
-
comments in the gist.
-
@JonB , thanks. Great comments. I have been working on it. It will take a few days before I upload again. But also have to learn about splitting the files up now. I have done it, but the imports not working as I thought they would. I got it working , but I can see it's not right. I did the init file and did the all list. But it's ok, I am missing something yet again in my understanding. I also made some comments at the gist. But I have uiLabel, uiButton, ui.TextField working ok at the moment. UiTextField using self as a delegate. Easy to have an external delegate.
But again thanks for your help. I am sure this is not a challenge for you. But I have to learn so many things along the way. But loving it 😳😱😛
-
@JonB , thanks. Great comments. I have been working on it. It will take a few days before I upload again. But also have to learn about splitting the files up now. I have done it, but the imports not working as I thought they would. I got it working , but I can see it's not right. I did the init file and did the all list. But it's ok, I am missing something yet again in my understanding. I also made some comments at the gist. But I have uiLabel, uiButton, ui.TextField working ok at the moment. UiTextField using self as a delegate. Easy to have an external delegate.
But again thanks for your help. I am sure this is not a challenge for you. But I have to learn so many things along the way. But loving it 😳😱😛
-
@JonB , thanks. Great comments. I have been working on it. It will take a few days before I upload again. But also have to learn about splitting the files up now. I have done it, but the imports not working as I thought they would. I got it working , but I can see it's not right. I did the init file and did the all list. But it's ok, I am missing something yet again in my understanding. I also made some comments at the gist. But I have uiLabel, uiButton, ui.TextField working ok at the moment. UiTextField using self as a delegate. Easy to have an external delegate.
But again thanks for your help. I am sure this is not a challenge for you. But I have to learn so many things along the way. But loving it 😳😱😛
-
@JonB , thanks. Great comments. I have been working on it. It will take a few days before I upload again. But also have to learn about splitting the files up now. I have done it, but the imports not working as I thought they would. I got it working , but I can see it's not right. I did the init file and did the all list. But it's ok, I am missing something yet again in my understanding. I also made some comments at the gist. But I have uiLabel, uiButton, ui.TextField working ok at the moment. UiTextField using self as a delegate. Easy to have an external delegate.
But again thanks for your help. I am sure this is not a challenge for you. But I have to learn so many things along the way. But loving it 😳😱😛
-
@JonB , I have put this in its own repo now. Look it's ugly. I am still working through it. I am slow though. It's quite evident there a lot a of things I don't understand. But hopefully as I keep working on it , it will start to take a better shape. Even the naming is crap 😀 Anyway, it's viewable and runnable.
The repo
-
@JonB , please be a little patient with me.i have had many visitors the last few days. I have been working on it when I get the chance. The current repo Not even worth looking at. Many things change. But in the finer details of implementing this, is getting very tricky. For me at least. The side effects are so hard work out.but, I will update the repo in a few days.
Basically saying I am still working on it. I think the next version will be ok. But I am still struggling with the structure of a package!
-
@JonB , after a long afternoon of trying understand the side effects I was creating, I have decided to go a different way. It gets worse when trying to add functionality to the class, which is the main intent. I am not giving up. I just dont think its a viable solution. I know you did it in a limited context.
I have thought of another way with just some wrapper functions. I am pretty sure i will be able to achieve almost all I wanted to do with a fraction of the code and side effects. Let's see 😱😳👍