ipywidgets
ipywidgets copied to clipboard
Add new description widget attribute specifically for the tooltip text
I think that ipywidget is great, therefore I venture with a suggestion. Presently a long widget description with not enough space to display produces dots, and a balloon when hovering over the text. The balloon is nice, the dots not so much.
In largish data analysis GUIs, very short help (i.e. a slightly longer description) would nicely fit, in my opinion, in a separate trait, that behaves like the balloon: the description is shown statically, the balloon is shown when hovering over the former.
Or in two separate parameters of the description, short and [long], the latter behaving like a balloon.
I hope you may consider it as a future feature, if others agree with the purpose.
Thank you so much Roberto
P.S the same applies to other widget/trait pairs that have the same functionality, e.g. ToggleButton/value
Many traits have a description attribute - are you proposing an additional description_long (or some similar name) which would populate the balloon tooltip?
In largish data analysis GUIs, very short help (i.e. a slightly longer description) would nicely fit, in my opinion, in a separate trait, that behaves like the balloon: the description is shown statically, the balloon is shown when hovering over the former.
Could you give some example code illustrating your idea?
Dear jasongrout, I hope this screenshot helps to understand what I mean. Not the best worked out example, I admit.

(btw, Markdown in the above figure does what I need, if you hover over the screenshot) The example in the screenshot is obtained exploiting a loooong description. With my proposal one could avoid the dots that cram the static GUI.
Regarding your previous question: I do not really know the ipywidgets innards. Syntactically it could be either an independent trait, e.g. description_long, or an optional separate parameter of description (like in the Markdown syntax, I suppose), performing the same functionality. I am not sure I have answered your questions.
Perhaps you wanted this. Present code in the screenshot:
self.plot_range = Text(description='plot range\nstart,stop\n[,pack]\n[last,pack]',
value='0,500',
layout=Layout(width='22%'),
continuous_update=False)
self.plot_range.style.description_width='36%'
self.plot_range.observe(on_range,'value')
Proposed code
self.plot_range = Text(description='plot range',
description_long='start,stop\n[,pack]\n[last,pack]',
value='0,500',
layout=Layout(width='22%'),
continuous_update=False)
self.plot_range.style.description_width='36%'
self.plot_range.observe(on_range,'value')
I think you can also put that info in the placeholder text, which is about as ephemeral as the tooltip:
Text(description='plot range', placeholder='start, stop[, pack] [last, pack]')
(There are concerns about putting instructions in the placeholder text, but I'm not sure it's any worse than putting it in a tooltip)
Thanks, I tried it, but the "balloon" still contains the text of the description, not the text that I inserted in placeholder.
Besides, I am missing the documentation for advanced features like placeholder (in readthedocs?) Can you please tell me where to look?
Thanks, I tried it, but the "balloon" still contains the text of the description, not the text that I inserted in placeholder.
Right - I was giving an alternate way to present that information to the user that works right now.
So perhaps the take-away here is to make a new attribute for description widgets (tooltip perhaps, which is a standard term for this, or maybe description_help?), and the tooltip defaults to the description.
sounds great Roberto
I changed the title to reflect this
Let me know if something else needs to be done.
I would like to outline another reason to deal with tooltip explicitly - for Labels in particular.
Let me try to phrase the issue I have encountered.
Problem: Unwanted tooltip over Label
Demo
Cf. demo notebook in nbviewer.
- Run the notebook 3 cells - or see the result on nbviewer (link above)
- Hover over the text 'My Label' and see the unwanted HTML/CSS :(
Explanation
The ipywidgets Label, which is part of many other core ipywidgets like XSliders, XText, DropDown, etc is the 'culprit'.
It passes the description string as HTML label properties innerHTML AND title. The latter is responsible for the tooltip.
I would argue that passing the argument to title is superfluous at best, and a hindrance when the description contains HTML/CSS that you do not want to show to users - as in the example below.
See source code: https://github.com/jupyter-widgets/ipywidgets/blob/2c8c82b0916707d73796a159a6c59f92cea38613/packages/controls/src/widget_description.ts#L75
Suggested Remedy
- Minimum: Remove the line singled out
- Better: Add new input
tooltipto widgetLabel.tooltipmaps to label HTML propertytitle.
If not specified, defaults todescriptioni.e. current case.
Do this remark / suggested remedy make sense ? If so, what is the recommended next step ?
For anyone trying to find how to add a tooltip when hovering over the description of a widget, use the argument description_tooltip

It looks to me that, as of 7.7.1 the description_tooltip, argument does not work for Dropdown. Is it a bug?