alejandroautalan / pygubu

A simple GUI builder for the python tkinter module
MIT License
2.01k stars 213 forks source link

class name #275

Closed YiQinHuili closed 4 months ago

YiQinHuili commented 1 year ago

Hi Alejandroautalan,

Thank you very much for the fantastic tool! After reviewing a number of tools I decided to use pygubu for my project - I found it the best in terms of ease to use, rich in feature and flexible.

I use it by generating the code script, sub-classing the generated class and overriding the call back functions - so that the automatically generated code and my hand writing code are completely separated. It worked perfectly until I decided to create a second top-level window - a simple dialog.

What is bothering me is that I have to re-type the class name every time I need to re-generate and save the code script. Could you please add the class name as an property in the "Appearance" panel, for example, under "id", and use it to generate the code?

Thanks again for your work - you are making our life much easier!

alejandroautalan commented 1 year ago

Hello @YiQinHuili, thanks for your comments. I will try to focus on this when I finish the customtkinter integration (in a few weeks)

Thanks again for your work - you are making our life much easier!

I'm glad that pygubu is helpful for you!

Regards Alejandro A.

BloodyRain2k commented 1 year ago

@YiQinHuili are you referring to this name field? image If that's the case, this field is using the ui file's name, along with some simple casing logic.

I've been looking into keeping that name too without relying on the ui file's name, but I didn't get very far yet.

Mostly because I settled on a work around to avoid needing the "Code" tab on every change: After I generate the initial UI, I generate the "App" code and save it in a separate .py file, usually <ProjectName>_Tk.py. Then I reference the class from that file in the actual project's .py file and run it from there. At this point I only need to make changes to the ui and ctrl+s to update the .ui file.

This should work in your case too, if you give your dialog a custom id. You can then access the dialog through the mainwindow's .builder: image In my case I have a tk.Frame named entry, which I intended to use as a blueprint for an instancing experiement, so I had to set the master manually to a new tkinter.TopLevel because it's just a tk.Frame, but in your case that might not be needed.

With this setup you rarely need to touch the "Code" tab as the builder has everything it needs in the .ui file. Maybe that helps as a work around for you too, until we've got some connection between toplevel elements and the names we gave them.

PS: don't be confused if the "App" code you generate might look different, I'm running modified versions of both the designer and builder.

alejandroautalan commented 4 months ago

Hi Alejandroautalan,

Thank you very much for the fantastic tool! After reviewing a number of tools I decided to use pygubu for my project - I found it the best in terms of ease to use, rich in feature and flexible.

I use it by generating the code script, sub-classing the generated class and overriding the call back functions - so that the automatically generated code and my hand writing code are completely separated. It worked perfectly until I decided to create a second top-level window - a simple dialog.

What is bothering me is that I have to re-type the class name every time I need to re-generate and save the code script. Could you please add the class name as an property in the "Appearance" panel, for example, under "id", and use it to generate the code?

Thanks again for your work - you are making our life much easier!

Project settings are now saved in the ui file, and used for code generation using the inheritance approach. Fixed in v0.35