Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Ui control subclassing [really good idea 😬]
-
I believe you will need to set flex='wh' in your obj, so that the encapsulated object follows your new class in terms of size(that is why I explicitly prevented frame parameters from getting passed to the encapsulated obj). Also, probably things like border, border_width, corner_radius and maybe a few others should not go to the encapsulated obj.
For buttons and other action-y things, presumably the point is to take some other action. So you might want special handling of action and delegate attributes (don't pass them on to obj). For instance, you would as part of the standard creation set up an _action, set obj.action=self._action, and in self._action you'd check self.action is present and callable, in which case you'd call it, perhaps before or after doing something custom. Delegate's need similar treatment, except you also maybe need to implement all standard delegate actions, so you can intercept and modify the way the delegates work.
-
@JonB , thanks. Yes I am working on that now. Gets confusing with get and set attributes being overriden . I have seen the warnings when reading about doing this before 😱
I understand the object, Call now. Calling the base class to avoid endless recursion. But unless I am mistaken I also have to add the ui_object to the view in ControlEx, I hadn't been doing that. But it makes sense I need to. I have done it now. Works more like I expect it to. I can see a title for expample 👍
But I will just keep working on it. LOL, no wonder I never finish anything 🤐Will also look at the delegates if I every get this part working
-
Is your intention that a developer would subclass ButtonExt? or _ButtonExt?
-
@JonB , _uiButtonEx. Well that's the idea. Not sure it's the correct idea. but from my comments , I can see why it's confusing. I have been getting confused myself. I am rewinding a lot now, because it's too complicated. Not the structure of the classes, just the attr stuff in ControlExt. I got a little carried away and I am lost with all the side effects. So will go back to your basic code, and start again in that class 😱😜
Only way to learn. -
@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 😱😳👍