theodox / mGui

Python module for cleaner maya GUI layout syntax
MIT License
123 stars 23 forks source link

YAML - like layout language? #65

Open theodox opened 7 years ago

theodox commented 7 years ago

What do people think about a Yaml-like declarative layout format for saving GUI as data? Is that a step forward or back? mGui.MenuLoader is great for menus, since there's a lot of boilerplate in making menus. Is it worth extending as whole layouts?

bob-white commented 7 years ago

So a kind of xaml for mGui?

theodox commented 7 years ago

yeah, that's the basic idea. Or more like QT uic files. I'm not sure how I feel about it though, it's good separation of concerns but the handshake between code and content gets messy. There's an old thread on TAO about this; Rob G is very anti 'gui as data' . I'm not sure how I feel.

dshlai commented 7 years ago

How would you like to handle event and callback binding? Would that happen inside the python code proper, after the ui is being serialized into python class? (I.e, like what we are doing now with pyside/pyqt)?

theodox commented 7 years ago

in the menuloader, I use fully qualifies names (see https://github.com/theodox/mGui/blob/master/mGui/menu_loader.py) to bind functions to events. That seems to work pretty well, although I'm sure you'd get some edge cases if there were a lot of dynamic loading going on

dshlai commented 7 years ago

another possible GUI language reference: https://kivy.org/docs/api-kivy.lang.html

theodox commented 7 years ago

This looks like a promising YAML alternative

https://code.google.com/archive/p/rson/ https://pypi.python.org/pypi/rsonlite/0.1.0

Rson is a syntax transform of Json, so it's just a formatting thing which I like

bob-white commented 7 years ago

I like the simple syntax, but we do lose a few features from yaml.

Of course the downside is it being a large-ish dependency, but its been pretty stable the last few years (one bugfix release?) and is thankfully pure python.

theodox commented 7 years ago

Looking at menuloader, it seems like we're not really leveraging much of the fanciness of yaml at all. It might be more flexible to rewrite the menuloader and other UI loaders off of pure python dictionaries instead of YamlObject and remove the dependency -- or at least, move it sideways into a separate thin wrapper that loaded any nested-dictionary style object graph.

That would sidestep both syntax wars and dependency management. It would probably also support xml as an alternative format for free.

Thoughts?

bob-white commented 7 years ago

A definite possibility. I did a quick test of converting the shelf_loader over to use pure dictionaries, loaded from a json file. https://github.com/bob-white/mGui/tree/shelf_no_yaml - didn't think it was worth a whole pull request. If this seems like a more agreeable path, I'll update the existing one to match.

Required fairly minimal changes from the yaml version. The data file is noisier, but a nice thing about acting on pure dictionaries is that anyone could write an adapter to their favorite serialization library without to much headache.

theodox commented 7 years ago

I think this might be the way to go, and then we can apply the same change to the menu loader and sorta-kinda get the gui layout language for free.