mirror of
https://github.com/zebrajr/faceswap.git
synced 2025-12-06 00:20:09 +01:00
GUI: Display paths in tooltips
This commit is contained in:
parent
9182c56921
commit
fa616ffea2
|
|
@ -21,13 +21,14 @@ logger = logging.getLogger(__name__) # pylint: disable=invalid-name
|
|||
_RECREATE_OBJECTS = dict(tooltips=dict(), commands=dict(), contextmenus=dict())
|
||||
|
||||
|
||||
def _get_tooltip(widget, text, wraplength=600):
|
||||
def _get_tooltip(widget, text=None, text_variable=None, wraplength=600):
|
||||
""" Store the tooltip layout and widget id in _TOOLTIPS and return a tooltip """
|
||||
_RECREATE_OBJECTS["tooltips"][str(widget)] = {"text": text,
|
||||
"text_variable": text_variable,
|
||||
"wraplength": wraplength}
|
||||
logger.debug("Adding to tooltips dict: (widget: %s. text: '%s', wraplength: %s)",
|
||||
widget, text, wraplength)
|
||||
return Tooltip(widget, text=text, wraplength=wraplength)
|
||||
return Tooltip(widget, text=text, text_variable=text_variable, wraplength=wraplength)
|
||||
|
||||
|
||||
def _get_contextmenu(widget):
|
||||
|
|
@ -832,7 +833,10 @@ class ControlBuilder():
|
|||
if self.option.control != ttk.Checkbutton:
|
||||
ctl.pack(padx=5, pady=5, fill=tk.X, expand=True)
|
||||
if self.option.helptext is not None and not self.helpset:
|
||||
_get_tooltip(ctl, text=self.option.helptext, wraplength=600)
|
||||
tooltip_kwargs = dict(text=self.option.helptext, wraplength=600)
|
||||
if self.option.sysbrowser is not None:
|
||||
tooltip_kwargs["text_variable"] = self.option.tk_var
|
||||
_get_tooltip(ctl, **tooltip_kwargs)
|
||||
|
||||
logger.debug("Built control: '%s'", self.option.name)
|
||||
|
||||
|
|
|
|||
|
|
@ -529,9 +529,8 @@ class StatusBar(ttk.Frame): # pylint: disable=too-many-ancestors
|
|||
self._pbar_position.set(position)
|
||||
|
||||
|
||||
class Tooltip:
|
||||
"""
|
||||
Create a tooltip for a given widget as the mouse goes on it.
|
||||
class Tooltip: # pylint:disable=too-few-public-methods
|
||||
""" Create a tooltip for a given widget as the mouse goes on it.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
|
@ -543,6 +542,9 @@ class Tooltip:
|
|||
(left, top, right, bottom) padding for the tool-tip. Default: (5, 3, 5, 3)
|
||||
text: str, optional
|
||||
The text to be displayed in the tool-tip. Default: 'widget info'
|
||||
text_variable: :class:`tkinter.strVar`, optional
|
||||
The text variable to use for dynamic help text. Appended after the contents of :attr:`text`
|
||||
if provided. Default: ``None``
|
||||
waittime: int, optional
|
||||
The time in milliseconds to wait before showing the tool-tip. Default: 400
|
||||
wraplength: int, optional
|
||||
|
|
@ -560,12 +562,13 @@ class Tooltip:
|
|||
http://www.daniweb.com/programming/software-development/code/484591/a-tooltip-class-for-tkinter
|
||||
"""
|
||||
def __init__(self, widget, *, background="#FFFFEA", pad=(5, 3, 5, 3), text="widget info",
|
||||
waittime=400, wraplength=250):
|
||||
text_variable=None, waittime=400, wraplength=250):
|
||||
|
||||
self._waittime = waittime # in milliseconds, originally 500
|
||||
self._wraplength = wraplength # in pixels, originally 180
|
||||
self._widget = widget
|
||||
self._text = text
|
||||
self._text_variable = text_variable
|
||||
self._widget.bind("<Enter>", self._on_enter)
|
||||
self._widget.bind("<Leave>", self._on_leave)
|
||||
self._widget.bind("<ButtonPress>", self._on_leave)
|
||||
|
|
@ -658,8 +661,12 @@ class Tooltip:
|
|||
win = tk.Frame(self._topwidget,
|
||||
background=background,
|
||||
borderwidth=0)
|
||||
|
||||
text = self._text
|
||||
if self._text_variable and self._text_variable.get():
|
||||
text += "\n\nCurrent value: '{}'".format(self._text_variable.get())
|
||||
label = tk.Label(win,
|
||||
text=self._text,
|
||||
text=text,
|
||||
justify=tk.LEFT,
|
||||
background=background,
|
||||
relief=tk.SOLID,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user