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

Added new FormElements to represent floats and string input text boxes #653

Merged
merged 5 commits into from
Jun 22, 2015

Conversation

JudoWill
Copy link
Contributor

@JudoWill JudoWill commented Jun 3, 2015

Some commits related to issues #650. @ChrisBeaumont , I'm getting a weird error related to saving the custom viewer, can you take a look and point me in the right direction.

Some doc changes are coming in the next push.

from ..custom_viewer import FormElement, NumberElement, \
ChoiceElement, CustomViewer, \
CustomSubsetState, AttributeInfo, \
FloatElement, TextBoxElement
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer using parentheses instead of backslashes

@ChrisBeaumont
Copy link
Member

Nice -- can you add a few screenshots to this PR?

What is the specific error message you get? For state saving to work you need to implement the state property (which it looks like you attempt to do via the ValueProperty descriptor. That descriptor auto-creates a state property that, behind the scenes, calls ui.value()/ui.setValue() -- but my guess is that ui.value() isn't a valid method on a text widget, so instead you need to manually implement the state getter/setter.

@classmethod
def recognizes(cls, params):
try:
if params.startswith('float'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should think about how exactly float and text widgets should be recognized -- what you have might be fine, but it's an important decision. Should we be considering other alternatives to 'float()' and 'str()'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree these may not be the best choices. I'm open to suggestions. I was thinking it would also be useful to recognize just floats ... something akin to a=2.7.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that might be a better option to start with (assuming it doesn't collide with any other FormElement -- I need to check). Likewise the text element could recognize strings (again, in a way that doesn't break the behavior of special strings like 'att')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I know the idea of the custom_viewers is to make things easier for non-developers; have you thought about allowing the settings definitions to recognize form elements directly? Something like:
cv = custom_viewer('CV', a=NumberElement(1, 10))

We could support both pretty easily.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea (I would probably docuement that that in the docstring, but perhaps not sphinx documentation)

@JudoWill
Copy link
Contributor Author

JudoWill commented Jun 3, 2015

@ChrisBeaumont , I'm putting together a medium-sized plugin using a subclass of the TextBoxElement to run a statsmodel formula. Since it requires a little subclassing of many core glue items I was going to write a Sphinx tutorial on all of those pieces. Do you want me to include it as part of this PR or as a different one?

@ChrisBeaumont
Copy link
Member

If it's equally convenient, 2 PRs is probably easier to review!

@JudoWill
Copy link
Contributor Author

JudoWill commented Jun 3, 2015

Done, let me spend a little time cleaning up and improving some test coverage and then I'll call this one ready.

@JudoWill
Copy link
Contributor Author

JudoWill commented Jun 4, 2015

screen shot 2015-06-03 at 5 24 27 pm

Boring-est custom_viewer using the text and number inputs.

@ChrisBeaumont ChrisBeaumont mentioned this pull request Jun 17, 2015
@astrofrog
Copy link
Member

@JudoWill - there is a real failure here with Python 2.6 due to the fact that 2.6 doesn't support the {} set notation (use set([]) instead). I suspect we'll drop Python 2.6 support soon, but not just yet.

@JudoWill
Copy link
Contributor Author

Fixed py26 issue. Ready to merge.

@ChrisBeaumont
Copy link
Member

Looks good to me! Thanks @JudoWill

@astrofrog
Copy link
Member

👍

astrofrog added a commit that referenced this pull request Jun 22, 2015
Added new FormElements to represent floats and string input text boxes
@astrofrog astrofrog merged commit acda314 into glue-viz:master Jun 22, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants