ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Add new description widget attribute specifically for the tooltip text

Open RDeRenzi opened this issue 7 years ago • 13 comments
trafficstars

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

RDeRenzi avatar Dec 08 '17 11:12 RDeRenzi

Many traits have a description attribute - are you proposing an additional description_long (or some similar name) which would populate the balloon tooltip?

jasongrout avatar Dec 08 '17 12:12 jasongrout

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?

jasongrout avatar Dec 08 '17 12:12 jasongrout

Dear jasongrout, I hope this screenshot helps to understand what I mean. Not the best worked out example, I admit.

fit_tab

(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.

RDeRenzi avatar Dec 08 '17 14:12 RDeRenzi

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')

RDeRenzi avatar Dec 08 '17 14:12 RDeRenzi

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)

jasongrout avatar Dec 08 '17 14:12 jasongrout

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?

RDeRenzi avatar Dec 08 '17 15:12 RDeRenzi

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.

jasongrout avatar Dec 08 '17 23:12 jasongrout

sounds great Roberto

RDeRenzi avatar Dec 09 '17 08:12 RDeRenzi

I changed the title to reflect this

jasongrout avatar Dec 09 '17 16:12 jasongrout

Let me know if something else needs to be done.

piyushrungta25 avatar May 10 '18 18:05 piyushrungta25

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 :(
ipywidget_unfortunate_tooltip

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

  1. Minimum: Remove the line singled out
  2. Better: Add new input tooltip to widget Label. tooltip maps to label HTML property title.
    If not specified, defaults to description i.e. current case.

Do this remark / suggested remedy make sense ? If so, what is the recommended next step ?

oscar6echo avatar Jun 21 '18 13:06 oscar6echo

For anyone trying to find how to add a tooltip when hovering over the description of a widget, use the argument description_tooltip

Screenshot from 2021-07-26 14-01-06

luiztauffer avatar Jul 26 '21 12:07 luiztauffer

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

RDeRenzi avatar Sep 22 '22 10:09 RDeRenzi