-
Notifications
You must be signed in to change notification settings - Fork 23
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
Possible method of making Compound Controls #84
Conversation
Initial example is an IntSpinner.
Also moved to using regular buttons with silly labels for now. Seems that `IconTextButton` has a minimum width that would cause it to overflow onto the `IntField`, and I'm not entirely sure what is causing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm interested in seeing what we can do to handle property and event forwarding from the components up to the main compound object.
In other words:: I'd like to write a class without too much custom code where my compound thing has a tree of widgets:
and have a nice, clean and clear way of setting properties on The tricky bit is how to make inot too painful to set up, ideally with a nice metaclass to make it really uncluttered |
So something along these lines class CompoundControlMeta(type):
# Some magic will happen here
pass
class CompoundControl:
__metaclass__ = CompoundControlMeta
class IntSpinner(CompoundControl):
_CONTROLS = {
'root': HorizontalStretchForm,
'field': IntField,
'label': Text,
'decrement': Button,
'increment': Button,
'form': VerticalStretchForm,
}
_HIERARCHY = {
'root': (
'label',
'field', {
'form': (
'increment',
'decrement'
)
}
)
}
Other issues:
|
I think I'm OK with the compound widget assembly process being code rather than data -- the list classes, which are effectively examples of compound widgets, needed some finagling to work the way I liked. At this early stage of the idea it feels like the main issue is a painless way for the owning compound object to expose properties correctly -- some of them will be unique to the compoiund and need custom code but some will basically be pass-throughs of properites on lower level stuff. I've been assuming that the |
Uses `__getattr__` and `__setattr__` to defer requests to the root control. Exposes the other controls as public fields.
Updated the PR with just another thought. Instead of subclassing any mGui object, this acts more as a facade. Each of the controls is exposed as a public field, so no need to generate properties to route information to them. Still have to manually generate any |
Might just throw this out, but don't want to lose it yet.
Initial example is an IntSpinner.
Based on the conversation over at TAO
Basically just expands the
IntField
with a newstep
value, and links the two buttons to increment and decrement the value.If we want to further expose the button commands, we'd need some kind of descriptor to route the
Events
from the sub commands, but that should be fairly simple.