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

Make label width configurable #1376

Merged
merged 6 commits into from
May 22, 2017
Merged

Conversation

jasongrout
Copy link
Member

@jasongrout jasongrout commented May 22, 2017

This implements the ideas behind #1373. The idea is that the current label width is still too brittle - we have a min and a max width, but it's too hard to get something much smaller or larger. This introduces a description_width style attribute which lets you easily set the width. As part of this, I eliminated the max-width on the label, since now it is very easy to extend the width of a label. For example, style=dict(description_width='initial') makes the label be exactly as long as the text.

This also affects the checkbox indent. @maxnoy - what do you think about description_width affecting the checkbox indent width? It seems a bit confusing that description_width affects the width of the indent, not the text.

from ipywidgets import *
style=dict(description_width='50px')
widgets = []
widgets.append(IntSlider(description='slide', style=style))
widgets.append(Dropdown(description='drop', style=style))
widgets.append(Checkbox(description='check', style=style))
VBox(widgets)

screen shot 2017-05-22 at 11 48 04 am

@@ -37,8 +38,15 @@ def remove_class(self, className):
return self


class DescriptionStyle(Style, Widget):
"""Button style widget."""
_model_name = Unicode('SliderStyleModel').tag(sync=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

misnamed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, thanks.

Thanks to @blink1073 for pointing this out.
Also, set the ‘for’ attribute correctly for accessibility.
@jasongrout
Copy link
Member Author

Opening another issue for discussion on the label width: #1377.

@jasongrout jasongrout merged commit d771e99 into jupyter-widgets:master May 22, 2017
@jasongrout jasongrout added this to the 7.0 milestone May 22, 2017
@jasongrout jasongrout mentioned this pull request May 22, 2017
@maxnoy
Copy link
Contributor

maxnoy commented May 23, 2017

@jasongrout, this seems like very useful functionality. Maybe if there was a notion of description_width vs content_width, it would be a bit clearer?

@jasongrout
Copy link
Member Author

I think we usually have the widgets automatically expand the content width, so there is a correlation between widget width and content width (i.e., to make the content wider, just make the widget wider).

Can we just handle this in documentation, with the explanation that the checkbox description is on the right?

@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants