new class foe tooltip
This commit is contained in:
parent
2a3bf2bbcb
commit
47bdfbfb17
Binary file not shown.
@ -390,6 +390,7 @@ def if_tip(path):
|
|||||||
tip = True
|
tip = True
|
||||||
return tip
|
return tip
|
||||||
|
|
||||||
|
|
||||||
class Tooltip:
|
class Tooltip:
|
||||||
"""
|
"""
|
||||||
class for Tooltip
|
class for Tooltip
|
||||||
@ -400,10 +401,12 @@ class Tooltip:
|
|||||||
examble: Tooltip(button, "Show tooltip on button")
|
examble: Tooltip(button, "Show tooltip on button")
|
||||||
info: label and button is parrent.
|
info: label and button is parrent.
|
||||||
"""
|
"""
|
||||||
def __init__(self, widget, text):
|
|
||||||
|
def __init__(self, widget, text, TIPS=None):
|
||||||
self.widget = widget
|
self.widget = widget
|
||||||
self.text = text
|
self.text = text
|
||||||
self.tooltip_window = None
|
self.tooltip_window = None
|
||||||
|
if TIPS:
|
||||||
self.widget.bind("<Enter>", self.show_tooltip)
|
self.widget.bind("<Enter>", self.show_tooltip)
|
||||||
self.widget.bind("<Leave>", self.hide_tooltip)
|
self.widget.bind("<Leave>", self.hide_tooltip)
|
||||||
|
|
||||||
@ -418,12 +421,12 @@ class Tooltip:
|
|||||||
tw.wm_overrideredirect(True)
|
tw.wm_overrideredirect(True)
|
||||||
tw.wm_geometry(f"+{x}+{y}")
|
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()
|
label.grid()
|
||||||
|
|
||||||
def hide_tooltip(self, event=None):
|
def hide_tooltip(self, event=None):
|
||||||
if self.tooltip_window:
|
if self.tooltip_window:
|
||||||
self.tooltip_window.destroy()
|
self.tooltip_window.destroy()
|
||||||
self.tooltip_window = None
|
self.tooltip_window = None
|
||||||
|
|
||||||
|
|
600
wirepy.py
600
wirepy.py
@ -23,7 +23,7 @@ Create.decrypt()
|
|||||||
|
|
||||||
tcl_path = Path("/usr/share/TK-Themes")
|
tcl_path = Path("/usr/share/TK-Themes")
|
||||||
wg_set = Path(Path.home() / ".config/wire_py/settings")
|
wg_set = Path(Path.home() / ".config/wire_py/settings")
|
||||||
WG_TIPS = if_tip(wg_set)
|
TIPS = if_tip(wg_set)
|
||||||
dirname = Path("/tmp/tlecdcwg/")
|
dirname = Path("/tmp/tlecdcwg/")
|
||||||
|
|
||||||
# 1 = 1. Year, 09 = Month of the Year, 2924 = Day and Year of the Year
|
# 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.configure(relief="flat")
|
||||||
self.menu_frame.grid(column=0, row=0, columnspan=4, sticky="w")
|
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
|
# App Menu
|
||||||
self.version_lb = ttk.Label(self.menu_frame, text=VERSION)
|
self.version_lb = ttk.Label(self.menu_frame, text=VERSION)
|
||||||
self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff")
|
self.version_lb.config(font=("Ubuntu", 11), foreground="#00c4ff")
|
||||||
self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
|
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 = ttk.Menubutton(self.menu_frame, text=_("Options"))
|
||||||
self.options_btn.grid(column=1, columnspan=1, row=0)
|
self.options_btn.grid(column=1, columnspan=1, row=0)
|
||||||
|
|
||||||
def sets_enter(event):
|
Tooltip(self.options_btn, _("Click for Settings"), TIPS)
|
||||||
"""
|
|
||||||
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)
|
|
||||||
|
|
||||||
set_update = tk.IntVar()
|
set_update = tk.IntVar()
|
||||||
set_tip = tk.BooleanVar()
|
set_tip = tk.BooleanVar()
|
||||||
@ -301,7 +270,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||||
|
|
||||||
# View Checkbox for enable or disable Tooltip
|
# View Checkbox for enable or disable Tooltip
|
||||||
if WG_TIPS:
|
if TIPS:
|
||||||
set_tip.set(value=False)
|
set_tip.set(value=False)
|
||||||
else:
|
else:
|
||||||
set_tip.set(value=True)
|
set_tip.set(value=True)
|
||||||
@ -311,47 +280,15 @@ class FrameWidgets(ttk.Frame):
|
|||||||
set_update.set(value=1)
|
set_update.set(value=1)
|
||||||
self.updates_lb.configure(text=_("Update search off"))
|
self.updates_lb.configure(text=_("Update search off"))
|
||||||
|
|
||||||
def disable_enter(event):
|
Tooltip(self.updates_lb, _("Updates you have disabled"), TIPS)
|
||||||
"""
|
|
||||||
The mouse moves into the entry widget
|
|
||||||
"""
|
|
||||||
window.my_tool_tip = MyToolTip(
|
|
||||||
event.x_root, event.y_root, _("Updates you have disabled")
|
|
||||||
)
|
|
||||||
|
|
||||||
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!":
|
elif res == "No Internet Connection!":
|
||||||
self.updates_lb.configure(text=_("No Server Connection!"), foreground="red")
|
self.updates_lb.configure(text=_("No Server Connection!"), foreground="red")
|
||||||
elif res == "No Updates":
|
elif res == "No Updates":
|
||||||
self.updates_lb.configure(text=_("No Updates"))
|
self.updates_lb.configure(text=_("No Updates"))
|
||||||
|
|
||||||
def congratulations_enter(event):
|
Tooltip(self.updates_lb, _("Congratulations! Wire-Py is up to date"), TIPS)
|
||||||
"""
|
|
||||||
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"),
|
|
||||||
)
|
|
||||||
|
|
||||||
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:
|
else:
|
||||||
set_update.set(value=0)
|
set_update.set(value=0)
|
||||||
text = f"Update {res} " + _("available!")
|
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 = ttk.Menubutton(self.menu_frame, text=text)
|
||||||
self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
|
self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
|
||||||
|
|
||||||
def download_enter(event):
|
Tooltip(self.update_btn, _("Click to download new version"), TIPS)
|
||||||
"""
|
|
||||||
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)
|
|
||||||
|
|
||||||
self.download = tk.Menu(self, relief="flat")
|
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.insert("end", tunnels[:-5])
|
||||||
self.l_box.update()
|
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
|
# Button Vpn
|
||||||
if self.a != "":
|
if self.a != "":
|
||||||
self.stop()
|
self.stop()
|
||||||
@ -538,23 +420,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
)
|
)
|
||||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||||
|
|
||||||
def imp_enter(event):
|
Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), TIPS)
|
||||||
"""
|
|
||||||
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)
|
|
||||||
|
|
||||||
def delete():
|
def delete():
|
||||||
"""
|
"""
|
||||||
@ -604,36 +470,27 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.wg_autostart.configure(state="disabled")
|
self.wg_autostart.configure(state="disabled")
|
||||||
|
|
||||||
# for disable checkbox when Listbox empty
|
# 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:
|
if self.l_box.size() == 0:
|
||||||
self.wg_autostart.configure(state="disabled")
|
self.wg_autostart.configure(state="disabled")
|
||||||
self.lb_rename.configure(state="disabled")
|
self.lb_rename.configure(state="disabled")
|
||||||
self.l_box.bind("<Enter>", list_empty_enter)
|
Tooltip(
|
||||||
self.l_box.bind("<Leave>", list_empty_leave)
|
self.l_box, _("You must first import\na Wireguard tunnel"), TIPS
|
||||||
self.wg_autostart.bind("<Enter>", chk_enter)
|
)
|
||||||
self.wg_autostart.bind("<Leave>", chk_leave)
|
Tooltip(
|
||||||
self.btn_tr.bind("<Enter>", empty_list_enter)
|
self.wg_autostart,
|
||||||
self.btn_tr.bind("<Leave>", empty_list_leave)
|
_(
|
||||||
self.btn_exp.bind("<Enter>", empty_list_enter)
|
"You must have at least one\ntunnel in the list,to use the autostart"
|
||||||
self.btn_exp.bind("<Leave>", empty_list_leave)
|
),
|
||||||
self.btn_stst.bind("<Enter>", empty_list_start_enter)
|
TIPS,
|
||||||
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.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!"))
|
self.lb_rename.insert(0, _("Max. 12 characters!"))
|
||||||
|
|
||||||
if self.a != "" and self.a == select_tl:
|
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)
|
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:
|
if self.l_box.size() == 0:
|
||||||
self.btn_tr.bind("<Enter>", empty_list_enter)
|
Tooltip(self.btn_tr, _("No tunnels to delete in the list"), TIPS)
|
||||||
self.btn_tr.bind("<Leave>", empty_list_leave)
|
|
||||||
else:
|
else:
|
||||||
self.btn_tr.bind("<Enter>", del_enter)
|
Tooltip(
|
||||||
self.btn_tr.bind("<Leave>", del_leave)
|
self.btn_tr,
|
||||||
|
_("Click to delete a Wireguard Tunnel\nSelect from the list!"),
|
||||||
|
TIPS,
|
||||||
|
)
|
||||||
|
|
||||||
# Button Export
|
# Button Export
|
||||||
self.btn_exp = ttk.Button(
|
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)
|
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:
|
if self.l_box.size() == 0:
|
||||||
self.btn_exp.bind("<Enter>", empty_list_enter)
|
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), TIPS)
|
||||||
self.btn_exp.bind("<Leave>", empty_list_leave)
|
|
||||||
else:
|
else:
|
||||||
self.btn_exp.bind("<Enter>", exp_enter)
|
Tooltip(
|
||||||
self.btn_exp.bind("<Leave>", exp_leave)
|
self.btn_exp,
|
||||||
|
_(" Click to export all\nWireguard Tunnel to Zipfile"),
|
||||||
|
TIPS,
|
||||||
|
)
|
||||||
|
|
||||||
# Label Entry
|
# Label Entry
|
||||||
self.lb_rename = ttk.Entry(self.lb_frame4, width=20)
|
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.insert(0, _("Max. 12 characters!"))
|
||||||
self.lb_rename.config(state="disable")
|
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:
|
if self.l_box.size() != 0:
|
||||||
self.lb_rename.bind("<Enter>", rename_enter)
|
Tooltip(
|
||||||
self.lb_rename.bind("<Leave>", rename_leave)
|
self.lb_rename,
|
||||||
|
_("To rename a tunnel, you need to\nselect a tunnel from the list"),
|
||||||
|
TIPS,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.lb_rename.bind("<Enter>", rename_no_active_enter)
|
Tooltip(
|
||||||
self.lb_rename.bind("<Leave>", rename_no_active_leave)
|
self.lb_rename,
|
||||||
|
_("To rename a tunnel, at least one must be in the list"),
|
||||||
|
TIPS,
|
||||||
|
)
|
||||||
|
|
||||||
def tl_rename():
|
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")
|
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:
|
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
||||||
|
|
||||||
def chk_a_enter(event):
|
Tooltip(
|
||||||
"""
|
self.wg_autostart, _("To use the autostart, enable this Checkbox"), TIPS
|
||||||
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)
|
|
||||||
|
|
||||||
if self.l_box.size() == 0:
|
if self.l_box.size() == 0:
|
||||||
self.wg_autostart.bind("<Enter>", chk_enter)
|
Tooltip(
|
||||||
self.wg_autostart.bind("<Leave>", chk_leave)
|
self.wg_autostart,
|
||||||
else:
|
_(
|
||||||
|
"You must have at least one\ntunnel in the list,to use the autostart"
|
||||||
def chk_a_enter(event):
|
),
|
||||||
"""
|
TIPS,
|
||||||
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(_):
|
else:
|
||||||
"""
|
|
||||||
The mouse moves into the entry widget
|
|
||||||
Remove Tool-Tip
|
|
||||||
"""
|
|
||||||
window.my_tool_tip.destroy()
|
|
||||||
|
|
||||||
self.wg_autostart.bind("<Enter>", chk_a_enter)
|
Tooltip(
|
||||||
self.wg_autostart.bind("<Leave>", chk_a_leave)
|
self.wg_autostart,
|
||||||
|
_("To use the autostart, a tunnel must be selected from the list"),
|
||||||
|
TIPS,
|
||||||
|
)
|
||||||
|
|
||||||
self.on_off()
|
self.on_off()
|
||||||
|
|
||||||
@ -1125,109 +855,41 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.l_box.update()
|
self.l_box.update()
|
||||||
self.l_box.selection_set(0)
|
self.l_box.selection_set(0)
|
||||||
|
|
||||||
def chk_a_enter(event):
|
Tooltip(
|
||||||
"""The mouse moves into the entry widget"""
|
self.wg_autostart,
|
||||||
window.my_tool_tip = MyToolTip(
|
_("To use the autostart, enable this Checkbox"),
|
||||||
event.x_root,
|
TIPS,
|
||||||
event.y_root,
|
)
|
||||||
|
|
||||||
|
# Tooltip(self.l_box, _("List of available tunnels"))
|
||||||
|
|
||||||
|
Tooltip(
|
||||||
|
self.btn_tr,
|
||||||
_(
|
_(
|
||||||
"To use the autostart, enable this "
|
"Click to delete a Wireguard Tunnel\n"
|
||||||
"Checkbox"
|
"Select from the list!"
|
||||||
),
|
),
|
||||||
|
TIPS,
|
||||||
)
|
)
|
||||||
|
|
||||||
def chk_a_leave(_):
|
Tooltip(
|
||||||
"""
|
self.btn_exp,
|
||||||
The mouse moves into the entry widget
|
|
||||||
Remove Tool-Tip
|
|
||||||
"""
|
|
||||||
window.my_tool_tip.destroy()
|
|
||||||
|
|
||||||
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"),
|
|
||||||
)
|
|
||||||
|
|
||||||
def list_info_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 "
|
" Click to export all\n"
|
||||||
"Tunnel\nSelect from the list!"
|
"Wireguard Tunnel to Zipfile"
|
||||||
),
|
),
|
||||||
|
TIPS,
|
||||||
)
|
)
|
||||||
|
|
||||||
def del_leave(_):
|
Tooltip(
|
||||||
"""
|
self.btn_rename,
|
||||||
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"
|
"To rename a tunnel, you need to\n"
|
||||||
"select a tunnel from the list"
|
"select a tunnel from the list"
|
||||||
),
|
),
|
||||||
|
TIPS,
|
||||||
)
|
)
|
||||||
|
|
||||||
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.lb_rename.insert(0, "Max. 12 characters!")
|
||||||
self.str_var = tk.StringVar()
|
self.str_var = tk.StringVar()
|
||||||
self.str_var.set(self.a)
|
self.str_var.set(self.a)
|
||||||
@ -1401,23 +1063,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
)
|
)
|
||||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||||
|
|
||||||
def stop_enter(event):
|
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), TIPS)
|
||||||
"""
|
|
||||||
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)
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
@ -1431,45 +1077,11 @@ class FrameWidgets(ttk.Frame):
|
|||||||
)
|
)
|
||||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
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()
|
tl = Tunnel.list()
|
||||||
if len(tl) == 0:
|
if len(tl) == 0:
|
||||||
self.btn_stst.bind("<Enter>", empty_list_start_enter)
|
Tooltip(self.btn_stst, _("No tunnels to start in the list"), TIPS)
|
||||||
self.btn_stst.bind("<Leave>", empty_list_start_leave)
|
|
||||||
else:
|
else:
|
||||||
self.btn_stst.bind("<Enter>", start_enter)
|
Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), TIPS)
|
||||||
self.btn_stst.bind("<Leave>", start_leave)
|
|
||||||
|
|
||||||
def color_label(self):
|
def color_label(self):
|
||||||
"""
|
"""
|
||||||
@ -1557,44 +1169,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
msg_window(iw, ii, wt, msg_t)
|
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__":
|
if __name__ == "__main__":
|
||||||
window = Wirepy()
|
window = Wirepy()
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user