-
Notifications
You must be signed in to change notification settings - Fork 950
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
Conversation
ipywidgets/widgets/domwidget.py
Outdated
@@ -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) |
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.
misnamed?
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.
Yep, thanks.
Thanks to @blink1073 for pointing this out.
Also, set the ‘for’ attribute correctly for accessibility.
Opening another issue for discussion on the label width: #1377. |
@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? |
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? |
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 checkboxindent
width? It seems a bit confusing thatdescription_width
affects the width of the indent, not the text.