You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've explored the feasibility of incorporating your code into an image-based implementation, introducing a few changes.
I have used this self for a personal project:
Here's the modified code snippet within the tkinter-tooltip==2.2.0 framework:
def__init__(
self,
widget: tk.Widget,
msg: str|list[str] |Callable[[], str|list[str]],
image_path: str=None, # New parameterimage_size: tuple[int, int] =None, # New parameter
#! This is added - Load the image if an image path is providedself.image=Noneifimage_pathisnotNone:
image=Image.open(image_path)
ifimage_sizeisnotNone:
image=image.resize(image_size)
self.image=ImageTk.PhotoImage(image)
#! Label instead of Message widgetlabel=tk.Label(self, textvariable=self.msgVar, image=self.image, **message_kwargs)
label.grid()
Advantages:
Enables the inclusion of images as tooltips, enhancing formatting options.
Offers increased flexibility in content presentation.
Drawbacks:
PILLOW or equivalent library is required as a dependency.
If only text is used; text alignment may not be optimal (observed in testing).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've explored the feasibility of incorporating your code into an image-based implementation, introducing a few changes.
I have used this self for a personal project:
Here's the modified code snippet within the tkinter-tooltip==2.2.0 framework:
Advantages:
Drawbacks:
Beta Was this translation helpful? Give feedback.
All reactions