Running .ui -> Python during CMake

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
onekk
Veteran
Posts: 6205
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Running .ui -> Python during CMake

Post by onekk »

chennes wrote: Tue Nov 23, 2021 1:48 pm The strategy I ended up using was to manually run uic on the ui file and include the resulting Python file manually in the git repo. ....
From my needs I 'have simply rewritten a minimal interface panel and some methods to create input fields for the interface to do similar things:
GUI-new.png
GUI-new.png (50.88 KiB) Viewed 495 times
It is not a big things, just some basic input fields, but with some "steroids" like limits and so on.

the creation is driven by a tuple holding the data

Code: Select all

# tuple holding interface data
# format (name (panel, type, unit, min, max, step, default), info)
fields = (
    ("ifi_sides", ("mn", "Box Sides", "mm", 3, 10, 1, 4),
        "Number of sides"),
    ("cbo_type",  ("mn", "Box Type", ("Closed", "Open", "Frame", "With Cover")),
        "Box Type"),
    ("ifd_hei", ("mn", "Box Height", "mm", 20, 800, 0.5, 200),
        "Box Height (along Y axis), for polygonal boxes this value is the " +
        "internal diameter, (apothem * 2)"),
    ("ifd_wid", ("mn", "Box Width", "mm", 20, 800, 0.5, 100),
        "Box Width (along X axis)"),
    ("ifd_dep", ("mn", "Box Depth", "mm", 20, 800, 0.5, 50),
        "Box Depth"),
    ("chb_ind", ("mn", "Inner Dims", True),
        "Given dimensions are inner dimensions"),
....        
each field name has first three letters indicating the type to drive the creation of the proper widget, ifi (input field integer), ifd (input field decimal), cbo (combobox), chb (checkbox).

the "field name" is used also to compose the exit dictionary with proper values when invoking a ReadData() methods so it is easy to guess things aorund the code.

If it will be useful for your FreeCAD work, we could talk maybe in PM.

Hoping having not bothered...

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply