new class foe tooltip
This commit is contained in:
parent
2a3bf2bbcb
commit
47bdfbfb17
Binary file not shown.
@ -188,7 +188,7 @@ class GiteaUpdate:
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
else:
|
||||
|
||||
|
||||
# img_w, img_i, w_title, w_txt hand over
|
||||
iw = r"/usr/share/icons/lx-icons/64/error.png"
|
||||
ii = down_not_ok_image
|
||||
@ -390,27 +390,30 @@ def if_tip(path):
|
||||
tip = True
|
||||
return tip
|
||||
|
||||
|
||||
class Tooltip:
|
||||
"""
|
||||
class for Tooltip
|
||||
class for Tooltip
|
||||
|
||||
imoprt 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):
|
||||
|
||||
def __init__(self, widget, text, TIPS=None):
|
||||
self.widget = widget
|
||||
self.text = text
|
||||
self.tooltip_window = None
|
||||
self.widget.bind("<Enter>", self.show_tooltip)
|
||||
self.widget.bind("<Leave>", self.hide_tooltip)
|
||||
if TIPS:
|
||||
self.widget.bind("<Enter>", self.show_tooltip)
|
||||
self.widget.bind("<Leave>", 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
|
||||
@ -418,12 +421,12 @@ class Tooltip:
|
||||
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 = 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ from subprocess import check_call
|
||||
path_to_file = Path(Path.home() / ".config/wire_py/settings")
|
||||
|
||||
with open(path_to_file, "r", encoding="utf-8") as a_con:
|
||||
|
||||
|
||||
# This funtion is for the independent autostart of the previously selected tunnel
|
||||
lines = a_con.readlines()
|
||||
a_con = lines[7].strip()
|
||||
|
624
wirepy.py
624
wirepy.py
@ -23,7 +23,7 @@ Create.decrypt()
|
||||
|
||||
tcl_path = Path("/usr/share/TK-Themes")
|
||||
wg_set = Path(Path.home() / ".config/wire_py/settings")
|
||||
WG_TIPS = if_tip(wg_set)
|
||||
TIPS = if_tip(wg_set)
|
||||
dirname = Path("/tmp/tlecdcwg/")
|
||||
|
||||
# 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year
|
||||
@ -233,48 +233,17 @@ class FrameWidgets(ttk.Frame):
|
||||
self.menu_frame.configure(relief="flat")
|
||||
self.menu_frame.grid(column=0, row=0, columnspan=4, sticky="w")
|
||||
|
||||
def version_enter(event):
|
||||
"""
|
||||
The mouse moves into the Version widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, f"Version: {VERSION[2:]}"
|
||||
)
|
||||
|
||||
def version_leave(_):
|
||||
"""
|
||||
The mouse moves from the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
# App Menu
|
||||
self.version_lb = ttk.Label(self.menu_frame, text=VERSION)
|
||||
self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff")
|
||||
self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
|
||||
|
||||
Tooltip(self.version_lb, f"Version: {VERSION[2:]}", TIPS)
|
||||
|
||||
self.options_btn = ttk.Menubutton(self.menu_frame, text=_("Options"))
|
||||
self.options_btn.grid(column=1, columnspan=1, row=0)
|
||||
|
||||
def sets_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Click for Settings")
|
||||
)
|
||||
|
||||
def sets_leave(_):
|
||||
"""
|
||||
The mouse moves from the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.version_lb.bind("<Enter>", version_enter)
|
||||
self.version_lb.bind("<Leave>", version_leave)
|
||||
self.options_btn.bind("<Enter>", sets_enter)
|
||||
self.options_btn.bind("<Leave>", sets_leave)
|
||||
Tooltip(self.options_btn, _("Click for Settings"), TIPS)
|
||||
|
||||
set_update = tk.IntVar()
|
||||
set_tip = tk.BooleanVar()
|
||||
@ -301,7 +270,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
|
||||
# View Checkbox for enable or disable Tooltip
|
||||
if WG_TIPS:
|
||||
if TIPS:
|
||||
set_tip.set(value=False)
|
||||
else:
|
||||
set_tip.set(value=True)
|
||||
@ -311,47 +280,15 @@ class FrameWidgets(ttk.Frame):
|
||||
set_update.set(value=1)
|
||||
self.updates_lb.configure(text=_("Update search off"))
|
||||
|
||||
def disable_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Updates you have disabled")
|
||||
)
|
||||
Tooltip(self.updates_lb, _("Updates you have disabled"), TIPS)
|
||||
|
||||
def disable_leave(_):
|
||||
"""
|
||||
The mouse moves from the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.updates_lb.bind("<Enter>", disable_enter)
|
||||
self.updates_lb.bind("<Leave>", disable_leave)
|
||||
elif res == "No Internet Connection!":
|
||||
self.updates_lb.configure(text=_("No Server Connection!"), foreground="red")
|
||||
elif res == "No Updates":
|
||||
self.updates_lb.configure(text=_("No Updates"))
|
||||
|
||||
def congratulations_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("Congratulations! Wire-Py is up to date"),
|
||||
)
|
||||
Tooltip(self.updates_lb, _("Congratulations! Wire-Py is up to date"), TIPS)
|
||||
|
||||
def congratulations_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.updates_lb.bind("<Enter>", congratulations_enter)
|
||||
self.updates_lb.bind("<Leave>", congratulations_leave)
|
||||
else:
|
||||
set_update.set(value=0)
|
||||
text = f"Update {res} " + _("available!")
|
||||
@ -360,23 +297,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.update_btn = ttk.Menubutton(self.menu_frame, text=text)
|
||||
self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
|
||||
|
||||
def download_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Click to download new version")
|
||||
)
|
||||
|
||||
def download_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.update_btn.bind("<Enter>", download_enter)
|
||||
self.update_btn.bind("<Leave>", download_leave)
|
||||
Tooltip(self.update_btn, _("Click to download new version"), TIPS)
|
||||
|
||||
self.download = tk.Menu(self, relief="flat")
|
||||
|
||||
@ -470,45 +391,6 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.insert("end", tunnels[:-5])
|
||||
self.l_box.update()
|
||||
|
||||
def list_empty_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("You must first import\na Wireguard tunnel"),
|
||||
)
|
||||
|
||||
def list_empty_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def list_not_empty_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Select a Tunnel")
|
||||
)
|
||||
|
||||
def list_not_empty_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
self.l_box.bind("<Enter>", list_empty_enter)
|
||||
self.l_box.bind("<Leave>", list_empty_leave)
|
||||
else:
|
||||
self.l_box.bind("<Enter>", list_not_empty_enter)
|
||||
self.l_box.bind("<Leave>", list_not_empty_leave)
|
||||
|
||||
# Button Vpn
|
||||
if self.a != "":
|
||||
self.stop()
|
||||
@ -538,23 +420,7 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||
|
||||
def imp_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Click to import a Wireguard Tunnel")
|
||||
)
|
||||
|
||||
def imp_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.btn_i.bind("<Enter>", imp_enter)
|
||||
self.btn_i.bind("<Leave>", imp_leave)
|
||||
Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), TIPS)
|
||||
|
||||
def delete():
|
||||
"""
|
||||
@ -604,36 +470,27 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
|
||||
# for disable checkbox when Listbox empty
|
||||
def empty_list_start_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("No tunnels to start in the list")
|
||||
)
|
||||
|
||||
def empty_list_start_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
self.lb_rename.configure(state="disabled")
|
||||
self.l_box.bind("<Enter>", list_empty_enter)
|
||||
self.l_box.bind("<Leave>", list_empty_leave)
|
||||
self.wg_autostart.bind("<Enter>", chk_enter)
|
||||
self.wg_autostart.bind("<Leave>", chk_leave)
|
||||
self.btn_tr.bind("<Enter>", empty_list_enter)
|
||||
self.btn_tr.bind("<Leave>", empty_list_leave)
|
||||
self.btn_exp.bind("<Enter>", empty_list_enter)
|
||||
self.btn_exp.bind("<Leave>", empty_list_leave)
|
||||
self.btn_stst.bind("<Enter>", empty_list_start_enter)
|
||||
self.btn_stst.bind("<Leave>", empty_list_start_leave)
|
||||
self.lb_rename.bind("<Enter>", rename_no_active_enter)
|
||||
self.lb_rename.bind("<Leave>", rename_no_active_leave)
|
||||
Tooltip(
|
||||
self.l_box, _("You must first import\na Wireguard tunnel"), TIPS
|
||||
)
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_(
|
||||
"You must have at least one\ntunnel in the list,to use the autostart"
|
||||
),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), TIPS)
|
||||
Tooltip(self.btn_stst, _("No tunnels to start in the list"), TIPS)
|
||||
Tooltip(
|
||||
self.lb_rename,
|
||||
_("To rename a tunnel, at least one must be in the list"),
|
||||
TIPS,
|
||||
)
|
||||
self.lb_rename.insert(0, _("Max. 12 characters!"))
|
||||
|
||||
if self.a != "" and self.a == select_tl:
|
||||
@ -677,44 +534,14 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
||||
|
||||
def empty_list_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("No tunnels to delete in the list")
|
||||
)
|
||||
|
||||
def empty_list_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def del_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("Click to delete a Wireguard Tunnel\nSelect from the list!"),
|
||||
)
|
||||
|
||||
def del_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
self.btn_tr.bind("<Enter>", empty_list_enter)
|
||||
self.btn_tr.bind("<Leave>", empty_list_leave)
|
||||
Tooltip(self.btn_tr, _("No tunnels to delete in the list"), TIPS)
|
||||
else:
|
||||
self.btn_tr.bind("<Enter>", del_enter)
|
||||
self.btn_tr.bind("<Leave>", del_leave)
|
||||
Tooltip(
|
||||
self.btn_tr,
|
||||
_("Click to delete a Wireguard Tunnel\nSelect from the list!"),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
# Button Export
|
||||
self.btn_exp = ttk.Button(
|
||||
@ -722,39 +549,14 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
||||
|
||||
def empty_list_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("No Tunnels in List for Export")
|
||||
)
|
||||
|
||||
empty_list_leave(_)
|
||||
|
||||
def exp_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(" Click to export all\nWireguard Tunnel to Zipfile"),
|
||||
)
|
||||
|
||||
def exp_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
self.btn_exp.bind("<Enter>", empty_list_enter)
|
||||
self.btn_exp.bind("<Leave>", empty_list_leave)
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), TIPS)
|
||||
else:
|
||||
self.btn_exp.bind("<Enter>", exp_enter)
|
||||
self.btn_exp.bind("<Leave>", exp_leave)
|
||||
Tooltip(
|
||||
self.btn_exp,
|
||||
_(" Click to export all\nWireguard Tunnel to Zipfile"),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
# Label Entry
|
||||
self.lb_rename = ttk.Entry(self.lb_frame4, width=20)
|
||||
@ -762,46 +564,18 @@ class FrameWidgets(ttk.Frame):
|
||||
self.lb_rename.insert(0, _("Max. 12 characters!"))
|
||||
self.lb_rename.config(state="disable")
|
||||
|
||||
def rename_no_active_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def rename_no_active_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("To rename a tunnel, at least one must be in the list"),
|
||||
)
|
||||
|
||||
def rename_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("To rename a tunnel, you need to\nselect a tunnel from the list"),
|
||||
)
|
||||
|
||||
def rename_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() != 0:
|
||||
self.lb_rename.bind("<Enter>", rename_enter)
|
||||
self.lb_rename.bind("<Leave>", rename_leave)
|
||||
Tooltip(
|
||||
self.lb_rename,
|
||||
_("To rename a tunnel, you need to\nselect a tunnel from the list"),
|
||||
TIPS,
|
||||
)
|
||||
else:
|
||||
self.lb_rename.bind("<Enter>", rename_no_active_enter)
|
||||
self.lb_rename.bind("<Leave>", rename_no_active_leave)
|
||||
Tooltip(
|
||||
self.lb_rename,
|
||||
_("To rename a tunnel, at least one must be in the list"),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
def tl_rename():
|
||||
|
||||
@ -921,72 +695,28 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.wg_autostart.grid(column=0, row=0, pady=15, padx=15, sticky="nw")
|
||||
|
||||
def chk_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(
|
||||
"You must have at least one\n"
|
||||
"tunnel in the list,to use the autostart"
|
||||
),
|
||||
)
|
||||
|
||||
def chk_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
||||
|
||||
def chk_a_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("To use the autostart, enable this Checkbox"),
|
||||
)
|
||||
|
||||
def chk_a_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.wg_autostart.bind("<Enter>", chk_a_enter)
|
||||
self.wg_autostart.bind("<Leave>", chk_a_leave)
|
||||
Tooltip(
|
||||
self.wg_autostart, _("To use the autostart, enable this Checkbox"), TIPS
|
||||
)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
self.wg_autostart.bind("<Enter>", chk_enter)
|
||||
self.wg_autostart.bind("<Leave>", chk_leave)
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_(
|
||||
"You must have at least one\ntunnel in the list,to use the autostart"
|
||||
),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
def chk_a_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("To use the autostart, a tunnel must be selected from the list"),
|
||||
)
|
||||
|
||||
def chk_a_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.wg_autostart.bind("<Enter>", chk_a_enter)
|
||||
self.wg_autostart.bind("<Leave>", chk_a_leave)
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_("To use the autostart, a tunnel must be selected from the list"),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
self.on_off()
|
||||
|
||||
@ -1125,109 +855,41 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.update()
|
||||
self.l_box.selection_set(0)
|
||||
|
||||
def chk_a_enter(event):
|
||||
"""The mouse moves into the entry widget"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(
|
||||
"To use the autostart, enable this "
|
||||
"Checkbox"
|
||||
),
|
||||
)
|
||||
Tooltip(
|
||||
self.wg_autostart,
|
||||
_("To use the autostart, enable this Checkbox"),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
def chk_a_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
# Tooltip(self.l_box, _("List of available tunnels"))
|
||||
|
||||
def list_info_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("List of available tunnels"),
|
||||
)
|
||||
Tooltip(
|
||||
self.btn_tr,
|
||||
_(
|
||||
"Click to delete a Wireguard Tunnel\n"
|
||||
"Select from the list!"
|
||||
),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
def list_info_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
Tooltip(
|
||||
self.btn_exp,
|
||||
_(
|
||||
" Click to export all\n"
|
||||
"Wireguard Tunnel to Zipfile"
|
||||
),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
def del_enter(event):
|
||||
"""The mouse moves into the entry widget"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(
|
||||
"Click to delete a Wireguard "
|
||||
"Tunnel\nSelect from the list!"
|
||||
),
|
||||
)
|
||||
Tooltip(
|
||||
self.btn_rename,
|
||||
_(
|
||||
"To rename a tunnel, you need to\n"
|
||||
"select a tunnel from the list"
|
||||
),
|
||||
TIPS,
|
||||
)
|
||||
|
||||
def del_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def exp_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(
|
||||
" Click to export "
|
||||
"all\nWireguard Tunnel to Zipfile"
|
||||
),
|
||||
)
|
||||
|
||||
def exp_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def rename_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_(
|
||||
"To rename a tunnel, you need to\n"
|
||||
"select a tunnel from the list"
|
||||
),
|
||||
)
|
||||
|
||||
def rename_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.wg_autostart.bind("<Enter>", chk_a_enter)
|
||||
self.wg_autostart.bind("<Leave>", chk_a_leave)
|
||||
self.l_box.bind("<Enter>", list_info_enter)
|
||||
self.l_box.bind("<Leave>", list_info_leave)
|
||||
self.btn_tr.bind("<Enter>", del_enter)
|
||||
self.btn_tr.bind("<Leave>", del_leave)
|
||||
self.btn_exp.bind("<Enter>", exp_enter)
|
||||
self.btn_exp.bind("<Leave>", exp_leave)
|
||||
self.lb_rename.bind("<Enter>", rename_enter)
|
||||
self.lb_rename.bind("<Leave>", rename_leave)
|
||||
self.lb_rename.insert(0, "Max. 12 characters!")
|
||||
self.str_var = tk.StringVar()
|
||||
self.str_var.set(self.a)
|
||||
@ -1369,7 +1031,7 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
shows data in the label
|
||||
"""
|
||||
|
||||
|
||||
# Address Label
|
||||
self.address = ttk.Label(
|
||||
self.lb_frame, textvariable=self.add, foreground="#0071ff"
|
||||
@ -1401,23 +1063,7 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||
|
||||
def stop_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("Click to stop selected Wireguard Tunnel")
|
||||
)
|
||||
|
||||
def stop_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
self.btn_stst.bind("<Enter>", stop_enter)
|
||||
self.btn_stst.bind("<Leave>", stop_leave)
|
||||
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), TIPS)
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
@ -1431,45 +1077,11 @@ class FrameWidgets(ttk.Frame):
|
||||
)
|
||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||
|
||||
def empty_list_start_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root, event.y_root, _("No tunnels to start in the list")
|
||||
)
|
||||
|
||||
def empty_list_start_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
def start_enter(event):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
"""
|
||||
window.my_tool_tip = MyToolTip(
|
||||
event.x_root,
|
||||
event.y_root,
|
||||
_("Click to start selected Wireguard Tunnel"),
|
||||
)
|
||||
|
||||
def start_leave(_):
|
||||
"""
|
||||
The mouse moves into the entry widget
|
||||
Remove Tool-Tip
|
||||
"""
|
||||
window.my_tool_tip.destroy()
|
||||
|
||||
tl = Tunnel.list()
|
||||
if len(tl) == 0:
|
||||
self.btn_stst.bind("<Enter>", empty_list_start_enter)
|
||||
self.btn_stst.bind("<Leave>", empty_list_start_leave)
|
||||
Tooltip(self.btn_stst, _("No tunnels to start in the list"), TIPS)
|
||||
else:
|
||||
self.btn_stst.bind("<Enter>", start_enter)
|
||||
self.btn_stst.bind("<Leave>", start_leave)
|
||||
Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), TIPS)
|
||||
|
||||
def color_label(self):
|
||||
"""
|
||||
@ -1557,44 +1169,6 @@ class FrameWidgets(ttk.Frame):
|
||||
msg_window(iw, ii, wt, msg_t)
|
||||
|
||||
|
||||
class MyToolTip(tk.Toplevel):
|
||||
"""
|
||||
Tooltip Class to view Tooltips
|
||||
"""
|
||||
|
||||
TIP_X_OFFSET = 20
|
||||
TIP_Y_OFFSET = 20
|
||||
if not WG_TIPS:
|
||||
AUTO_CLEAR_TIME = 0
|
||||
else:
|
||||
AUTO_CLEAR_TIME = 2000 # Millisecond. (1/200 sec.)
|
||||
|
||||
def __init__(self, x_pos, y_pos, message=None, auto_clear=True):
|
||||
self.x_pos = x_pos
|
||||
self.y_pos = y_pos
|
||||
self.message = message
|
||||
self.auto_clear = auto_clear
|
||||
|
||||
tk.Toplevel.__init__(self)
|
||||
self.overrideredirect(True)
|
||||
|
||||
self.message_label = ttk.Label(
|
||||
self, compound="left", text=self.message, padding=6
|
||||
)
|
||||
self.message_label.pack()
|
||||
|
||||
self.geometry(
|
||||
f"+{self.x_pos + self.TIP_X_OFFSET}+{self.y_pos + self.TIP_X_OFFSET}"
|
||||
)
|
||||
|
||||
if self.auto_clear:
|
||||
self.after(self.AUTO_CLEAR_TIME, self.clear_tip)
|
||||
|
||||
def clear_tip(self):
|
||||
"""Remove Tool-Tip"""
|
||||
self.destroy()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
window = Wirepy()
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user