vanilla icon indicating copy to clipboard operation
vanilla copied to clipboard

Request: unified way to add tooltips

Open mekkablue opened this issue 4 years ago • 2 comments

Right now, I need to access the NS object and call its setToolTip: function. The problem is that the object getter is syntactically different for each vanilla object:

self.w.myTextField.getNSTextField().setToolTip_("Tooltip text.")
self.w.myPopupButton.getNSPopUpButton().setToolTip_("Tooltip text.")

How about something like this instead:

self.w.myTextField.tooltip("Tooltip text.")
self.w.myPopupButton.tooltip("Tooltip text.")

Or am I overthinking the issue?

mekkablue avatar May 10 '21 10:05 mekkablue

Yes, but: self.myTextField.setToolTip("...").

Both NSView and NSControl support the setToolTip_ method, so adding setToolTip to VanillaBaseObject would cover a lot of cases.

Would you like to make a PR?

justvanrossum avatar May 10 '21 11:05 justvanrossum

hi Just :) , just added PR. I hope it looks ok

RafalBuchner avatar May 11 '21 12:05 RafalBuchner

Thanks @RafalBuchner!

import vanilla

w = vanilla.Window((200, 40))
w.b = vanilla.Button((10, 10, -10, 20), "Hover Over Me")
w.b.setToolTip("Thanks @RafalBuchner :)")
w.open()

typesupply avatar Dec 20 '23 17:12 typesupply