optimize performance 06-05-2025
This commit is contained in:
parent
d0aed9e253
commit
dba6138aa7
4
.idea/workspace.xml
generated
4
.idea/workspace.xml
generated
@ -6,7 +6,7 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Update Translate Files">
|
||||
<change afterPath="$PROJECT_DIR$/.vscode/settings.json" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cls_mth_fc.py" beforeDir="false" afterPath="$PROJECT_DIR$/cls_mth_fc.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/common_tools.py" beforeDir="false" afterPath="$PROJECT_DIR$/common_tools.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ssl_decrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssl_decrypt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ssl_encrypt.py" beforeDir="false" afterPath="$PROJECT_DIR$/ssl_encrypt.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/wirepy.py" beforeDir="false" afterPath="$PROJECT_DIR$/wirepy.py" afterDir="false" />
|
||||
@ -51,7 +51,7 @@
|
||||
"keyToString": {
|
||||
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||
"Python.INSTALL.executor": "Run",
|
||||
"Python.cls_mth_fc.executor": "Run",
|
||||
"Python.common_tools.executor": "Run",
|
||||
"Python.install.executor": "Run",
|
||||
"Python.main.executor": "Run",
|
||||
"Python.messagebox.executor": "Run",
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -2,5 +2,5 @@
|
||||
"workbench.settings.openDefaultSettings": true
|
||||
"workbench.startupEditor": "none"
|
||||
"update.showReleaseNotes": false
|
||||
"terminal.integrated.fontSize": 22
|
||||
"terminal.integrated.fontSize": 18
|
||||
}
|
@ -3,7 +3,7 @@ My standard System: Linux Mint 22 Cinnamon
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- os import in cls_mth_fc.py replaced by other methods
|
||||
- os import in common_tools.py replaced by other methods
|
||||
- If Wire-Py already runs, prevent further start
|
||||
- for loops with lists replaced by List Comprehensions
|
||||
|
||||
|
Binary file not shown.
BIN
__pycache__/common_tools.cpython-312.pyc
Normal file
BIN
__pycache__/common_tools.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -394,7 +394,7 @@ class ConfigManager:
|
||||
cls._config = {
|
||||
'updates': lines[1].strip(),
|
||||
'theme': lines[3].strip(),
|
||||
'tooltips': lines[5].strip() == 'True',
|
||||
'tooltips': lines[5].strip() == "True", # is converted here to boolean!!!
|
||||
'autostart': lines[7].strip() if len(lines) > 7 else 'off'
|
||||
}
|
||||
except (IndexError, FileNotFoundError):
|
||||
@ -402,7 +402,7 @@ class ConfigManager:
|
||||
cls._config = {
|
||||
'updates': 'on',
|
||||
'theme': 'light',
|
||||
'tooltips': True,
|
||||
'tooltips': "True", # Default Value as string !
|
||||
'autostart': 'off'
|
||||
}
|
||||
return cls._config
|
||||
@ -532,57 +532,72 @@ class GiteaUpdate:
|
||||
LxTools.msg_window(AppConfig.IMAGE_PATHS["icon_error"], AppConfig.IMAGE_PATHS["icon_msg"], wt, msg_t)
|
||||
|
||||
|
||||
class Tooltip:
|
||||
"""
|
||||
class for Tooltip
|
||||
|
||||
import Tooltip
|
||||
|
||||
class Tooltip():
|
||||
"""Class for Tooltip
|
||||
from common_tools.py import Tooltip
|
||||
example: Tooltip(label, "Show tooltip on label")
|
||||
example: Tooltip(button, "Show tooltip on button")
|
||||
info: label and button are parent.
|
||||
example: Tooltip(widget, "Text", state_var=tk.BooleanVar())
|
||||
|
||||
info: label and button are parent widgets.
|
||||
NOTE: When using with state_var, pass the tk.BooleanVar object directly,
|
||||
NOT its value. For example: use state_var=my_bool_var, NOT state_var=my_bool_var.get()
|
||||
"""
|
||||
|
||||
def __init__(self, widget: Any, text: str, tips: Optional[bool] = None) -> None:
|
||||
"""
|
||||
Tooltip Class
|
||||
"""
|
||||
|
||||
def __init__(self, widget: Any, text: str, state_var: Optional[tk.BooleanVar] = None) -> None:
|
||||
"""Tooltip Class"""
|
||||
self.widget: Any = widget
|
||||
self.text: str = text
|
||||
self.tooltip_window: Optional[Toplevel] = None
|
||||
if tips:
|
||||
self.state_var = state_var
|
||||
|
||||
# Initial binding based on current state
|
||||
self.update_bindings()
|
||||
|
||||
# Add trace to the state_var if provided
|
||||
if self.state_var is not None:
|
||||
self.state_var.trace_add("write", self.update_bindings)
|
||||
|
||||
def update_bindings(self, *args) -> None:
|
||||
"""Updates the bindings based on the current state"""
|
||||
# Remove existing bindings first
|
||||
self.widget.unbind("<Enter>")
|
||||
self.widget.unbind("<Leave>")
|
||||
|
||||
# Add new bindings if tooltips are enabled
|
||||
if self.state_var is None or self.state_var.get():
|
||||
self.widget.bind("<Enter>", self.show_tooltip)
|
||||
self.widget.bind("<Leave>", self.hide_tooltip)
|
||||
|
||||
|
||||
def show_tooltip(self, event: Optional[Any] = None) -> None:
|
||||
"""
|
||||
Shows the tooltip
|
||||
"""
|
||||
"""Shows the tooltip"""
|
||||
if self.tooltip_window or not self.text:
|
||||
return
|
||||
|
||||
|
||||
x: int
|
||||
y: int
|
||||
cx: int
|
||||
cy: int
|
||||
|
||||
x, y, cx, cy = self.widget.bbox("insert")
|
||||
x += self.widget.winfo_rootx() + 65
|
||||
y += self.widget.winfo_rooty() + 40
|
||||
|
||||
self.tooltip_window = tw = tk.Toplevel(self.widget)
|
||||
tw.wm_overrideredirect(True)
|
||||
tw.wm_geometry(f"+{x}+{y}")
|
||||
|
||||
label: tk.Label = tk.Label(tw, text=self.text, background="lightgreen", foreground="black", relief="solid",
|
||||
borderwidth=1, padx=5, pady=5)
|
||||
|
||||
label: tk.Label = tk.Label(
|
||||
tw, text=self.text, background="lightgreen", foreground="black",
|
||||
relief="solid", borderwidth=1, padx=5, pady=5
|
||||
)
|
||||
label.grid()
|
||||
|
||||
self.tooltip_window.after(2200, lambda: tw.destroy())
|
||||
|
||||
|
||||
def hide_tooltip(self, event: Optional[Any] = None) -> None:
|
||||
"""
|
||||
Hides the tooltip
|
||||
"""
|
||||
"""Hides the tooltip"""
|
||||
if self.tooltip_window:
|
||||
self.tooltip_window.destroy()
|
||||
self.tooltip_window = None
|
||||
|
||||
|
10
install
10
install
@ -17,7 +17,7 @@ install_file_with(){
|
||||
exit 0
|
||||
else
|
||||
sudo apt install python3-tk && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -uR lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -fv Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -43,7 +43,7 @@ install_arch_d(){
|
||||
exit 0
|
||||
else
|
||||
sudo pacman -S --noconfirm tk python3 python-requests && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -uR lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -fv Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -120,7 +120,7 @@ install(){
|
||||
exit 0
|
||||
else
|
||||
sudo dnf install python3-tkinter -y
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -uR lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -fv Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -145,7 +145,7 @@ install(){
|
||||
rm -r ~/.config/wire_py && rm -r ~/.config/systemd
|
||||
exit 0
|
||||
else
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py cls_mth_fc.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -fv wirepy.py start_wg.py wp_app_config.py common_tools.py ssl_encrypt.py ssl_decrypt.py /usr/local/bin/ && \
|
||||
sudo cp -uR lx-icons /usr/share/icons/ && sudo cp -uR TK-Themes /usr/share/ && \
|
||||
sudo cp -u languages/de/*.mo /usr/share/locale/de/LC_MESSAGES/ && \
|
||||
sudo cp -fv Wire-Py.desktop /usr/share/applications/ && \
|
||||
@ -181,7 +181,7 @@ install(){
|
||||
|
||||
remove(){
|
||||
sudo rm -f /usr/local/bin/wirepy /usr/local/bin/wirepy.py /usr/local/bin/start_wg.py \
|
||||
/usr/local/bin/wp_app_config.py cls_mth_fc.py /usr/local/bin/ssl_encrypt.py /usr/local/bin/ssl_decrypt.py
|
||||
/usr/local/bin/wp_app_config.py common_tools.py /usr/local/bin/ssl_encrypt.py /usr/local/bin/ssl_decrypt.py
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
exit 0
|
||||
|
@ -2,7 +2,7 @@
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import filedialog, ttk
|
||||
from cls_mth_fc import Create, LxTools
|
||||
from common_tools import Create, LxTools
|
||||
from wp_app_config import AppConfig, Msg
|
||||
import gettext
|
||||
import locale
|
||||
|
@ -5,7 +5,7 @@ import os
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from cls_mth_fc import LxTools
|
||||
from common_tools import LxTools
|
||||
from wp_app_config import AppConfig
|
||||
|
||||
#uname: Path = Path("/tmp/.log_user")
|
||||
|
138
wirepy.py
138
wirepy.py
@ -14,7 +14,7 @@ from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from tkinter import TclError, filedialog, ttk
|
||||
|
||||
from cls_mth_fc import (ConfigManager, ThemeManager, Create, GiteaUpdate, Tunnel, Tooltip, LxTools)
|
||||
from common_tools import (ConfigManager, ThemeManager, Create, GiteaUpdate, Tunnel, Tooltip, LxTools)
|
||||
from wp_app_config import AppConfig, Msg
|
||||
|
||||
LxTools.uos()
|
||||
@ -43,6 +43,7 @@ class Wirepy(tk.Tk):
|
||||
ConfigManager.init(AppConfig.SETTINGS_FILE)
|
||||
theme = ConfigManager.get("theme")
|
||||
ThemeManager.change_theme(self, theme)
|
||||
|
||||
# Load the image file from the disk
|
||||
self.wg_icon = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_vpn"])
|
||||
|
||||
@ -56,16 +57,15 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
ttk frame class for better structure
|
||||
"""
|
||||
def __init__(self, container, tips_enabled=None, **kwargs):
|
||||
def __init__(self, container, **kwargs):
|
||||
super().__init__(container, **kwargs)
|
||||
|
||||
|
||||
self.lb_tunnel = None
|
||||
self.btn_stst = None
|
||||
self.endpoint = None
|
||||
self.dns = None
|
||||
self.address = None
|
||||
self.auto_con = None
|
||||
self.tips_enabled = tips_enabled
|
||||
self.style = ttk.Style()
|
||||
self.wg_vpn_start = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_start"])
|
||||
self.wg_vpn_stop = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_stop"])
|
||||
@ -73,10 +73,26 @@ class FrameWidgets(ttk.Frame):
|
||||
self.tr_pic = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_trash"])
|
||||
self.exp_pic = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_export"])
|
||||
self.warning_pic = tk.PhotoImage(file=AppConfig.IMAGE_PATHS["icon_error"])
|
||||
self.tips_enabled = tips_enabled if tips_enabled is not None else ConfigManager.get("tooltip")
|
||||
|
||||
# StringVar-Variables initialization
|
||||
self.update_label = tk.StringVar()
|
||||
self.update_tooltip = tk.StringVar()
|
||||
self.tooltip_state = tk.BooleanVar()
|
||||
# Get value from configuration
|
||||
state = ConfigManager.get("tooltips")
|
||||
# NOTE: ConfigManager.get("tooltips") can return either a boolean value or a string,
|
||||
# depending on whether the value was loaded from the file (bool) or the default value is used (string).
|
||||
# The expression 'lines[5].strip() == "True"' in ConfigManager.load() converts the string to a boolean.
|
||||
# Convert to boolean and set
|
||||
if isinstance(state, bool):
|
||||
# If it's already a boolean, use directly
|
||||
self.tooltip_state.set(state)
|
||||
else:
|
||||
# If it's a string or something else
|
||||
self.tooltip_state.set(str(state) == "True")
|
||||
|
||||
self.tooltip_label = tk.StringVar() # StringVar-Variable for tooltip label for view Disabled/Enabled
|
||||
self.tooltip_update_label()
|
||||
self.update_label = tk.StringVar() # StringVar-Variable for update label
|
||||
self.update_tooltip = tk.StringVar() # StringVar-Variable for update tooltip please not remove!
|
||||
self.update_foreground = tk.StringVar(value="red")
|
||||
|
||||
# Frame for Menu
|
||||
@ -89,25 +105,25 @@ class FrameWidgets(ttk.Frame):
|
||||
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: {AppConfig.VERSION[2:]}", self.tips_enabled)
|
||||
Tooltip(self.version_lb, f"Version: {AppConfig.VERSION[2:]}", self.tooltip_state)
|
||||
|
||||
self.options_btn = ttk.Menubutton(self.menu_frame, text=_("Options"))
|
||||
self.options_btn.grid(column=1, columnspan=1, row=0)
|
||||
|
||||
Tooltip(self.options_btn, _("Click for Settings"), self.tips_enabled)
|
||||
Tooltip(self.options_btn, _("Click for Settings"), self.tooltip_state)
|
||||
|
||||
self.set_update = tk.IntVar()
|
||||
self.set_tip = tk.BooleanVar()
|
||||
self.settings = tk.Menu(self, relief="flat")
|
||||
self.options_btn.configure(menu=self.settings, style="Toolbutton")
|
||||
self.settings.add_checkbutton(label=_("Disable Updates"),
|
||||
command=lambda: self.update_setting(self.set_update.get()), variable=self.set_update)
|
||||
self.settings.add_command(label=_("Disable Tooltips"),
|
||||
command=lambda: self.tooltip(self.set_tip.get()), variable=self.set_tip)
|
||||
|
||||
self.updates_lb = ttk.Label(self.menu_frame)
|
||||
res = GiteaUpdate.api_down(AppConfig.UPDATE_URL, AppConfig.VERSION, ConfigManager.get("updates"))
|
||||
self.update_ui_for_update(res)
|
||||
|
||||
# Tooltip Menu
|
||||
self.settings.add_command(label=self.tooltip_label.get(), command=self.tooltips_toggle)
|
||||
# Label show dark or light
|
||||
self.theme_label = tk.StringVar()
|
||||
self.update_theme_label()
|
||||
@ -119,10 +135,6 @@ class FrameWidgets(ttk.Frame):
|
||||
self.about_btn.grid(column=2, columnspan=2, row=0)
|
||||
self.readme = tk.Menu(self)
|
||||
|
||||
|
||||
# View Checkbox to enable or disable Tooltip
|
||||
self.set_tip.set(value=not self.tips_enabled)
|
||||
|
||||
self.a = Tunnel.active()
|
||||
|
||||
# Label Frame 1
|
||||
@ -204,7 +216,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic, command=self.import_sl, padding=0)
|
||||
self.btn_i.grid(column=0, row=1, padx=15, pady=8)
|
||||
|
||||
Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), self.tips_enabled)
|
||||
Tooltip(self.btn_i, _("Click to import a Wireguard Tunnel"), self.tooltip_state)
|
||||
|
||||
# Button Trash
|
||||
self.btn_tr = ttk.Button(self.lb_frame_btn_lbox, image=self.tr_pic, command=self.delete, padding=0,
|
||||
@ -212,9 +224,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(self.btn_tr, _("No tunnels to delete in the list"), self.tips_enabled)
|
||||
Tooltip(self.btn_tr, _("No tunnels to delete in the list"), self.tooltip_state)
|
||||
else:
|
||||
Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!"), self.tips_enabled)
|
||||
Tooltip(self.btn_tr, _("Click to delete a Wireguard Tunnel\nSelect from the list!"), self.tooltip_state)
|
||||
|
||||
# Button Export
|
||||
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic,
|
||||
@ -226,9 +238,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), self.tips_enabled)
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), self.tooltip_state)
|
||||
else:
|
||||
Tooltip(self.btn_exp, _("Click to export all\nWireguard Tunnel to Zipfile"), self.tips_enabled)
|
||||
Tooltip(self.btn_exp, _("Click to export all\nWireguard Tunnel to Zipfile"), self.tooltip_state)
|
||||
|
||||
# Label Entry
|
||||
self.lb_rename = ttk.Entry(self.lb_frame4, width=20)
|
||||
@ -237,9 +249,9 @@ class FrameWidgets(ttk.Frame):
|
||||
self.lb_rename.config(state="disable")
|
||||
|
||||
if self.l_box.size() != 0:
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, you need to\nselect a tunnel from the list"), self.tips_enabled)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, you need to\nselect a tunnel from the list"), self.tooltip_state)
|
||||
else:
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), self.tips_enabled)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), self.tooltip_state)
|
||||
|
||||
# Button Rename
|
||||
self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=self.tl_rename,
|
||||
@ -260,14 +272,14 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.grid(column=0, row=0, pady=15, padx=15, sticky="nw")
|
||||
|
||||
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], tself.tips_enabled)
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], self.tooltip_state)
|
||||
|
||||
if self.l_box.size() == 0:
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart_info"], self.tips_enabled)
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart_info"], self.tooltip_state)
|
||||
|
||||
else:
|
||||
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], self.tips_enabled)
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], self.tooltip_state)
|
||||
|
||||
self.on_off()
|
||||
|
||||
@ -290,7 +302,7 @@ class FrameWidgets(ttk.Frame):
|
||||
foreground=self.update_foreground.get()
|
||||
)
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tips_enabled)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tooltip_state)
|
||||
|
||||
elif res == "No Internet Connection!":
|
||||
self.update_label.set(_("No Server Connection!"))
|
||||
@ -322,7 +334,7 @@ class FrameWidgets(ttk.Frame):
|
||||
foreground=self.update_foreground.get()
|
||||
)
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tips_enabled)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tooltip_state)
|
||||
|
||||
else:
|
||||
self.set_update.set(value=0)
|
||||
@ -336,7 +348,7 @@ class FrameWidgets(ttk.Frame):
|
||||
# Create the update button if it doesn't exist yet
|
||||
self.update_btn = ttk.Menubutton(self.menu_frame, text=update_text)
|
||||
self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
|
||||
Tooltip(self.update_btn, _("Click to download new version"), self.tips_enabled)
|
||||
Tooltip(self.update_btn, _("Click to download new version"), self.tooltip_state)
|
||||
|
||||
self.download = tk.Menu(self, relief="flat")
|
||||
self.update_btn.configure(menu=self.download, style="Toolbutton")
|
||||
@ -350,8 +362,8 @@ class FrameWidgets(ttk.Frame):
|
||||
AppConfig.IMAGE_PATHS["icon_error"],
|
||||
AppConfig.IMAGE_PATHS["icon_msg"]
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
def tooltip(self, tip) -> None:
|
||||
"""
|
||||
Aktualisiert die Tooltip-Einstellung im ConfigManager
|
||||
@ -361,7 +373,7 @@ class FrameWidgets(ttk.Frame):
|
||||
# Beachten Sie die umgekehrte Logik: tip=True bedeutet Tooltips deaktivieren
|
||||
ConfigManager.set("tooltip", not tip)
|
||||
# Aktualisieren Sie die lokale Variable für sofortige Wirkung
|
||||
self.tips_enabled = not tip
|
||||
self.tooltip_state = not tip
|
||||
|
||||
@staticmethod
|
||||
def about() -> None:
|
||||
@ -403,7 +415,7 @@ class FrameWidgets(ttk.Frame):
|
||||
foreground=self.update_foreground.get()
|
||||
)
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tips_enabled)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tooltip_state)
|
||||
|
||||
elif res == "No Internet Connection!":
|
||||
self.update_label.set(_("No Server Connection!"))
|
||||
@ -427,7 +439,7 @@ class FrameWidgets(ttk.Frame):
|
||||
foreground=self.update_foreground.get()
|
||||
)
|
||||
self.updates_lb.grid(column=4, columnspan=3, row=0, padx=10)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tips_enabled)
|
||||
Tooltip(self.updates_lb, self.update_tooltip.get(), self.tooltip_state)
|
||||
|
||||
else:
|
||||
# We have an update available
|
||||
@ -443,7 +455,7 @@ class FrameWidgets(ttk.Frame):
|
||||
# Create the update button if it doesn't exist yet
|
||||
self.update_btn = ttk.Menubutton(self.menu_frame, text=update_text)
|
||||
self.update_btn.grid(column=4, columnspan=3, row=0, padx=0)
|
||||
Tooltip(self.update_btn, _("Click to download new version"), self.tips_enabled)
|
||||
Tooltip(self.update_btn, _("Click to download new version"), self.tooltip_state)
|
||||
|
||||
self.download = tk.Menu(self, relief="flat")
|
||||
self.update_btn.configure(menu=self.download, style="Toolbutton")
|
||||
@ -510,13 +522,35 @@ class FrameWidgets(ttk.Frame):
|
||||
# Fallback to a default message if there's an error
|
||||
self.update_ui_for_update_status("No Internet Connection!")
|
||||
|
||||
def update_tooletip_label(self) -> str:
|
||||
"""Update the theme label based on current theme"""
|
||||
current_value = ConfigManager.get("tooletip")
|
||||
if current_value == "True":
|
||||
self.set_tip.set(_("Enable Tooltips"))
|
||||
def tooltip_update_label(self) -> None:
|
||||
"""Updates the tooltip menu label based on the current tooltip status"""
|
||||
# Set the menu text based on the current status
|
||||
if self.tooltip_state.get():
|
||||
# If tooltips are enabled, the menu option should be to disable them
|
||||
self.tooltip_label.set(_("Disable Tooltips"))
|
||||
else:
|
||||
self.set_tip.set(_("Disable Tooltips"))
|
||||
# If tooltips are disabled, the menu option should be to enable them
|
||||
self.tooltip_label.set(_("Enable Tooltips"))
|
||||
|
||||
|
||||
def tooltips_toggle(self):
|
||||
"""Toggles tooltips on/off and updates the menu label"""
|
||||
# Toggle the boolean state
|
||||
new_bool_state = not self.tooltip_state.get()
|
||||
|
||||
# Save the converted value in the configuration
|
||||
ConfigManager.set("tooltips", str(new_bool_state))
|
||||
print(f"Tooltips are now: {new_bool_state} in ConfigManager")
|
||||
# Update the tooltip_state variable for immediate effect
|
||||
self.tooltip_state.set(new_bool_state)
|
||||
|
||||
# Update the menu label
|
||||
self.tooltip_update_label()
|
||||
|
||||
# Update the menu entry - find the correct index
|
||||
# This assumes it's the third item (index 2) in your menu
|
||||
self.settings.entryconfigure(1, label=self.tooltip_label.get())
|
||||
|
||||
|
||||
def update_theme_label(self) -> str:
|
||||
"""Update the theme label based on current theme"""
|
||||
@ -546,9 +580,9 @@ class FrameWidgets(ttk.Frame):
|
||||
|
||||
tl = LxTools.get_file_name(AppConfig.TEMP_DIR)
|
||||
if len(self.tl) == 0:
|
||||
Tooltip(self.btn_stst, Msg.TTIP["empty_list"], self.tips_enabled)
|
||||
Tooltip(self.btn_stst, Msg.TTIP["empty_list"], self.tooltip_state)
|
||||
else:
|
||||
Tooltip(self.btn_stst, Msg.TTIP["start_tl"], self.tips_enabled)
|
||||
Tooltip(self.btn_stst, Msg.TTIP["start_tl"], self.tooltip_state)
|
||||
|
||||
def handle_tunnel_data(self, tunnel_name: str) -> tuple[str, str, str, str | None]:
|
||||
"""_summary_
|
||||
@ -588,7 +622,7 @@ class FrameWidgets(ttk.Frame):
|
||||
command=lambda: self.wg_switch("stop"), padding=0)
|
||||
self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
|
||||
|
||||
Tooltip(self.btn_stst, Msg.TTIP["stop_tl"], self.tips_enabled)
|
||||
Tooltip(self.btn_stst, Msg.TTIP["stop_tl"], self.tooltip_state)
|
||||
|
||||
def reset_fields(self) -> None:
|
||||
"""
|
||||
@ -664,10 +698,10 @@ class FrameWidgets(ttk.Frame):
|
||||
self.l_box.update()
|
||||
self.l_box.selection_set(0)
|
||||
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], self.tips_enabled)
|
||||
Tooltip(self.btn_tr, Msg.TTIP["trash_tl"], self.tips_enabled)
|
||||
Tooltip(self.btn_exp, Msg.TTIP["export_tl"], self.tips_enabled)
|
||||
Tooltip(self.btn_rename, Msg.TTIP["rename_tl"], self.tips_enabled)
|
||||
Tooltip(self.wg_autostart, Msg.TTIP["autostart"], self.tooltip_state)
|
||||
Tooltip(self.btn_tr, Msg.TTIP["trash_tl"], self.tooltip_state)
|
||||
Tooltip(self.btn_exp, Msg.TTIP["export_tl"], self.tooltip_state)
|
||||
Tooltip(self.btn_rename, Msg.TTIP["rename_tl"], self.tooltip_state)
|
||||
|
||||
self.lb_rename.insert(0, "Max. 12 characters!")
|
||||
self.str_var = tk.StringVar()
|
||||
@ -730,11 +764,11 @@ class FrameWidgets(ttk.Frame):
|
||||
self.wg_autostart.configure(state="disabled")
|
||||
self.lb_rename.configure(state="disabled")
|
||||
Tooltip(self.wg_autostart, _("You must have at least one\ntunnel in the list,to use the autostart")
|
||||
, self.tips_enabled)
|
||||
, self.tooltip_state)
|
||||
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), self.tips_enabled)
|
||||
Tooltip(self.btn_stst, _("No tunnels to start in the list"), self.tips_enabled)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), tips, )
|
||||
Tooltip(self.btn_exp, _("No Tunnels in List for Export"), self.tooltip_state)
|
||||
Tooltip(self.btn_stst, _("No tunnels to start in the list"), self.tooltip_state)
|
||||
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), self.tooltip_state)
|
||||
self.lb_rename.insert(0, _("Max. 12 characters!"))
|
||||
|
||||
if self.a != "" and self.a == select_tl:
|
||||
|
@ -30,13 +30,6 @@ class AppConfig:
|
||||
UPDATE_URL: str = "https://git.ilunix.de/api/v1/repos/punix/Wire-Py/releases"
|
||||
DOWNLOAD_URL: str = "https://git.ilunix.de/punix/Wire-Py/archive"
|
||||
|
||||
# Default settings
|
||||
DEFAULT_SETTINGS: Dict[str, Any] = {
|
||||
"updates": "on",
|
||||
"theme": "light",
|
||||
"tooltip": True,
|
||||
"autostart": "off"
|
||||
}
|
||||
|
||||
# UI configuration
|
||||
UI_CONFIG: Dict[str, Any] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user