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

Add new description widget attribute specifically for the tooltip text #1864

Open
RDeRenzi opened this issue Dec 8, 2017 · 13 comments
Open
Milestone

Comments

@RDeRenzi
Copy link

RDeRenzi commented Dec 8, 2017

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

@jasongrout
Copy link
Member

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

@jasongrout
Copy link
Member

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 jasongrout added this to the Future milestone Dec 8, 2017
@RDeRenzi
Copy link
Author

RDeRenzi commented Dec 8, 2017

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
Copy link
Author

RDeRenzi commented Dec 8, 2017

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

@jasongrout
Copy link
Member

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)

@RDeRenzi
Copy link
Author

RDeRenzi commented Dec 8, 2017

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?

@jasongrout
Copy link
Member

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.

@RDeRenzi
Copy link
Author

RDeRenzi commented Dec 9, 2017

sounds great Roberto

@jasongrout jasongrout changed the title Balloons for widgets Add new description widget attribute specifically for the tooltip text Dec 9, 2017
@jasongrout
Copy link
Member

I changed the title to reflect this

@piyushrungta25
Copy link
Contributor

Let me know if something else needs to be done.

@oscar6echo
Copy link
Contributor

oscar6echo commented Jun 21, 2018

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:

this.label.title = description;

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 ?

jasongrout added a commit that referenced this issue Jul 6, 2018
Add tooltip attribute to description widgets #1864
@luiztauffer
Copy link

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

@RDeRenzi
Copy link
Author

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

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

No branches or pull requests

5 participants