diff --git a/__pycache__/cls_mth_fc.cpython-312.pyc b/__pycache__/cls_mth_fc.cpython-312.pyc index d2a4eeb..18c17c4 100644 Binary files a/__pycache__/cls_mth_fc.cpython-312.pyc and b/__pycache__/cls_mth_fc.cpython-312.pyc differ diff --git a/cls_mth_fc.py b/cls_mth_fc.py index 48025c6..fa16c27 100755 --- a/cls_mth_fc.py +++ b/cls_mth_fc.py @@ -389,3 +389,41 @@ def if_tip(path): else: tip = True return tip + +class Tooltip: + """ + class for Tooltip + + imoprt Tooltip + + example: Tooltip(label, "Show tooltip on label") + examble: Tooltip(button, "Show tooltip on button") + info: label and button is parrent. + """ + def __init__(self, widget, text): + self.widget = widget + self.text = text + self.tooltip_window = None + self.widget.bind("", self.show_tooltip) + self.widget.bind("", self.hide_tooltip) + + def show_tooltip(self, event=None): + if self.tooltip_window or not self.text: + return + + x, y, _, _ = self.widget.bbox("insert") + x += self.widget.winfo_rootx() + 25 + y += self.widget.winfo_rooty() + 20 + self.tooltip_window = tw = tk.Toplevel(self.widget) + tw.wm_overrideredirect(True) + tw.wm_geometry(f"+{x}+{y}") + + label = tk.Label(tw, text=self.text, relief="solid", borderwidth=1, padx=5, pady=5) + label.grid() + + def hide_tooltip(self, event=None): + if self.tooltip_window: + self.tooltip_window.destroy() + self.tooltip_window = None + + \ No newline at end of file diff --git a/wirepy.py b/wirepy.py index c5108ab..c073737 100755 --- a/wirepy.py +++ b/wirepy.py @@ -14,7 +14,7 @@ import tkinter as tk from pathlib import Path from subprocess import check_call from tkinter import filedialog, ttk, TclError -from cls_mth_fc import Tunnel, Create, msg_window, if_tip, GiteaUpdate, uos +from cls_mth_fc import Tooltip, Tunnel, Create, msg_window, if_tip, GiteaUpdate, uos uos() Create.dir_and_files()