Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML - like layout language? #65

Open
theodox opened this issue Jan 14, 2017 · 10 comments
Open

YAML - like layout language? #65

theodox opened this issue Jan 14, 2017 · 10 comments
Labels

Comments

@theodox
Copy link
Owner

theodox commented Jan 14, 2017

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
Copy link
Collaborator

So a kind of xaml for mGui?

@theodox
Copy link
Owner Author

theodox commented Jan 14, 2017

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
Copy link

dshlai commented Jan 15, 2017

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
Copy link
Owner Author

theodox commented Jan 15, 2017

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
Copy link

dshlai commented Jan 15, 2017

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

@theodox
Copy link
Owner Author

theodox commented Jan 22, 2017

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
Copy link
Collaborator

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

  • Serialize arbitrary objects - json dialects are limited to basic primitives
  • Circular references - might be needed when dealing with formLayouts, and data bindings
  • Comments - more useful in config, but you never know.
  • Clean multi-line text blocks - really handy in the shelf loader.

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
Copy link
Owner Author

theodox commented Jan 22, 2017

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
Copy link
Collaborator

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
Copy link
Owner Author

theodox commented Jan 23, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants