method info and update to staticmethod

This commit is contained in:
Désiré Werner Menrath 2025-04-28 21:16:21 +02:00
parent 3039dbecb0
commit 53f66ea76d
2 changed files with 47 additions and 40 deletions

44
.idea/workspace.xml generated
View File

@ -5,7 +5,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Update Translate Files"> <list default="true" id="940e1630-c825-4d4c-be80-bc11f543c122" name="Changes" comment=" - Update Translate Files">
<change beforePath="$PROJECT_DIR$/cls_mth_fc.py" beforeDir="false" afterPath="$PROJECT_DIR$/cls_mth_fc.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/wirepy.py" beforeDir="false" afterPath="$PROJECT_DIR$/wirepy.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/wirepy.py" beforeDir="false" afterPath="$PROJECT_DIR$/wirepy.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -43,28 +43,28 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;, "ASKED_ADD_EXTERNAL_FILES": "true",
&quot;Python.INSTALL.executor&quot;: &quot;Run&quot;, "Python.INSTALL.executor": "Run",
&quot;Python.cls_mth_fc.executor&quot;: &quot;Run&quot;, "Python.cls_mth_fc.executor": "Run",
&quot;Python.install.executor&quot;: &quot;Run&quot;, "Python.install.executor": "Run",
&quot;Python.main.executor&quot;: &quot;Run&quot;, "Python.main.executor": "Run",
&quot;Python.messagebox.executor&quot;: &quot;Run&quot;, "Python.messagebox.executor": "Run",
&quot;Python.start_wg.executor&quot;: &quot;Run&quot;, "Python.start_wg.executor": "Run",
&quot;Python.testtheme.executor&quot;: &quot;Run&quot;, "Python.testtheme.executor": "Run",
&quot;Python.wg_func.executor&quot;: &quot;Run&quot;, "Python.wg_func.executor": "Run",
&quot;Python.wg_main.executor&quot;: &quot;Run&quot;, "Python.wg_main.executor": "Run",
&quot;Python.wirepy.executor&quot;: &quot;Run&quot;, "Python.wirepy.executor": "Run",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, "RunOnceActivity.git.unshallow": "true",
&quot;Shell Script.install.executor&quot;: &quot;Run&quot;, "Shell Script.install.executor": "Run",
&quot;Shell Script.run_as.executor&quot;: &quot;Run&quot;, "Shell Script.run_as.executor": "Run",
&quot;git-widget-placeholder&quot;: &quot;21-04-2025-new-tooltip&quot;, "git-widget-placeholder": "28-04-2025-more-methods-and-optimize-methods",
&quot;last_opened_file_path&quot;: &quot;/home/punix/Pyapps/wire-py&quot;, "last_opened_file_path": "/home/punix/Pyapps/wire-py",
&quot;settings.editor.selected.configurable&quot;: &quot;ml.llm.LLMConfigurable&quot; "settings.editor.selected.configurable": "ml.llm.LLMConfigurable"
} }
}</component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/lx-icons" /> <recent name="$PROJECT_DIR$/lx-icons" />

View File

@ -131,8 +131,10 @@ class FrameWidgets(ttk.Frame):
set_tip = tk.BooleanVar() set_tip = tk.BooleanVar()
self.settings = tk.Menu(self, relief="flat") self.settings = tk.Menu(self, relief="flat")
self.options_btn.configure(menu=self.settings, style="Toolbutton") self.options_btn.configure(menu=self.settings, style="Toolbutton")
self.settings.add_checkbutton(label=_("Disable Updates"), command=lambda: self.update(set_update.get()), variable=set_update) self.settings.add_checkbutton(label=_("Disable Updates"),
self.settings.add_checkbutton(label=_("Disable Tooltips"), command=lambda: self.tooltip(set_tip.get()), variable=set_tip) command=lambda: self.update_setting(set_update.get()), variable=set_update)
self.settings.add_checkbutton(label=_("Disable Tooltips"),
command=lambda: self.tooltip(set_tip.get()), variable=set_tip)
self.settings.add_command(label=_("Light"), command=self.theme_change_light) self.settings.add_command(label=_("Light"), command=self.theme_change_light)
self.settings.add_command(label=_("Dark"), command=self.theme_change_dark) self.settings.add_command(label=_("Dark"), command=self.theme_change_dark)
@ -300,14 +302,14 @@ class FrameWidgets(ttk.Frame):
Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), tips) Tooltip(self.lb_rename, _("To rename a tunnel, at least one must be in the list"), tips)
# Button Rename # Button Rename
self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=self.tl_rename, padding=4, self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=self.tl_rename,
style="RnButton.TButton") padding=4, style="RnButton.TButton")
self.btn_rename.grid(column=3, row=0, padx=5, pady=10, sticky="ne") self.btn_rename.grid(column=3, row=0, padx=5, pady=10, sticky="ne")
# Check Buttons # Check Buttons
self.selected_option = tk.IntVar() self.selected_option = tk.IntVar()
self.autoconnect_var = tk.StringVar() self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con) self.autoconnect_var.set(f"{self.auto_con}")
# Frame for Labels, Entry and Button # Frame for Labels, Entry and Button
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15) self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15)
@ -329,8 +331,9 @@ class FrameWidgets(ttk.Frame):
self.on_off() self.on_off()
def info(self): @staticmethod
def link_btn(): def info():
def link_btn() -> str | None:
webbrowser.open("https://git.ilunix.de/punix/Wire-Py") webbrowser.open("https://git.ilunix.de/punix/Wire-Py")
msg_t = _("Wire-Py a simple Wireguard Gui for Linux systems.\n\n" msg_t = _("Wire-Py a simple Wireguard Gui for Linux systems.\n\n"
@ -366,7 +369,8 @@ class FrameWidgets(ttk.Frame):
theme_set2.writelines(lines4) theme_set2.writelines(lines4)
self.color_label() self.color_label()
def update(self, update_res): @staticmethod
def update_setting(update_res):
""" """
write off or on in file write off or on in file
Args: Args:
@ -385,8 +389,9 @@ class FrameWidgets(ttk.Frame):
lines2[1] = "on\n" lines2[1] = "on\n"
with open(set_file, "w", encoding="utf-8") as set_f2: with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2) set_f2.writelines(lines2)
def tooltip(self, tip) -> None: @staticmethod
def tooltip(tip) -> None:
""" """
write True or False in a file write True or False in a file
Args: Args:
@ -651,14 +656,14 @@ class FrameWidgets(ttk.Frame):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
print("Tunnel exist!") print("Tunnel exist!")
def handle_tunnel_data(self, tunnel_name: str) -> dict[str, str]: def handle_tunnel_data(self, tunnel_name: str) -> tuple[str, str, str, str | None]:
"""_summary_ """_summary_
Args: Args:
tunnel_name (str): name of tunnel tunnel_name (str): name of a tunnel
Returns: Returns:
Dict[str, str]: dictionary with tunneldata tuple[str, str]: tuple with tunnel data
""" """
wg_read = f"/tmp/tlecdcwg/{tunnel_name}.conf" wg_read = f"/tmp/tlecdcwg/{tunnel_name}.conf"
@ -670,7 +675,7 @@ class FrameWidgets(ttk.Frame):
def box_set(self): def box_set(self):
""" """
This Method will display the autostart label which This Method will display the autostarted label which
Tunnel is automatically started regardless of the active tunnel. Tunnel is automatically started regardless of the active tunnel.
The selected tunnel is written into a file to read it after the start of the system. The selected tunnel is written into a file to read it after the start of the system.
""" """
@ -776,7 +781,8 @@ class FrameWidgets(ttk.Frame):
""" """
Stop Button Stop Button
""" """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, command=lambda: self.wg_switch("stop"), padding=0) self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop,
command=lambda: self.wg_switch("stop"), padding=0)
self.btn_stst.grid(column=0, row=0, padx=5, pady=8) self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips) Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
@ -785,7 +791,8 @@ class FrameWidgets(ttk.Frame):
""" """
Start Button Start Button
""" """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=lambda: self.wg_switch("start"), padding=0) self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start,
command=lambda: self.wg_switch("start"), padding=0)
self.btn_stst.grid(column=0, row=0, padx=5, pady=8) self.btn_stst.grid(column=0, row=0, padx=5, pady=8)
tl = Tunnel.list() tl = Tunnel.list()
@ -839,11 +846,11 @@ class FrameWidgets(ttk.Frame):
def handle_connection_state(self, action: str, tunnel_name: str = None) -> None: def handle_connection_state(self, action: str, tunnel_name: str = None) -> None:
""" """
Central management for connection states central management for connection states
Args: Args:
action (str): "start", "stop" or "toggle" action (str): "start", "stop" or "toggle"
tunnel_name (str, optional): name of tunnel for start-option. defaults to None. tunnel_name (str, optional): name of a tunnel for a start-option. defaults to None.
""" """
if action == "stop": if action == "stop":
if self.a: if self.a: