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 name="ChangeListManager">
<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" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -43,28 +43,28 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;Python.INSTALL.executor&quot;: &quot;Run&quot;,
&quot;Python.cls_mth_fc.executor&quot;: &quot;Run&quot;,
&quot;Python.install.executor&quot;: &quot;Run&quot;,
&quot;Python.main.executor&quot;: &quot;Run&quot;,
&quot;Python.messagebox.executor&quot;: &quot;Run&quot;,
&quot;Python.start_wg.executor&quot;: &quot;Run&quot;,
&quot;Python.testtheme.executor&quot;: &quot;Run&quot;,
&quot;Python.wg_func.executor&quot;: &quot;Run&quot;,
&quot;Python.wg_main.executor&quot;: &quot;Run&quot;,
&quot;Python.wirepy.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;Shell Script.install.executor&quot;: &quot;Run&quot;,
&quot;Shell Script.run_as.executor&quot;: &quot;Run&quot;,
&quot;git-widget-placeholder&quot;: &quot;21-04-2025-new-tooltip&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/punix/Pyapps/wire-py&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;ml.llm.LLMConfigurable&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"Python.INSTALL.executor": "Run",
"Python.cls_mth_fc.executor": "Run",
"Python.install.executor": "Run",
"Python.main.executor": "Run",
"Python.messagebox.executor": "Run",
"Python.start_wg.executor": "Run",
"Python.testtheme.executor": "Run",
"Python.wg_func.executor": "Run",
"Python.wg_main.executor": "Run",
"Python.wirepy.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"Shell Script.install.executor": "Run",
"Shell Script.run_as.executor": "Run",
"git-widget-placeholder": "28-04-2025-more-methods-and-optimize-methods",
"last_opened_file_path": "/home/punix/Pyapps/wire-py",
"settings.editor.selected.configurable": "ml.llm.LLMConfigurable"
}
}</component>
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/lx-icons" />

View File

@ -131,8 +131,10 @@ class FrameWidgets(ttk.Frame):
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(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_checkbutton(label=_("Disable Updates"),
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=_("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)
# Button Rename
self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=self.tl_rename, padding=4,
style="RnButton.TButton")
self.btn_rename = ttk.Button(self.lb_frame4, text=_("Rename"), state="disable", command=self.tl_rename,
padding=4, style="RnButton.TButton")
self.btn_rename.grid(column=3, row=0, padx=5, pady=10, sticky="ne")
# Check Buttons
self.selected_option = tk.IntVar()
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
self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15)
@ -329,8 +331,9 @@ class FrameWidgets(ttk.Frame):
self.on_off()
def info(self):
def link_btn():
@staticmethod
def info():
def link_btn() -> str | None:
webbrowser.open("https://git.ilunix.de/punix/Wire-Py")
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)
self.color_label()
def update(self, update_res):
@staticmethod
def update_setting(update_res):
"""
write off or on in file
Args:
@ -385,8 +389,9 @@ class FrameWidgets(ttk.Frame):
lines2[1] = "on\n"
with open(set_file, "w", encoding="utf-8") as set_f2:
set_f2.writelines(lines2)
def tooltip(self, tip) -> None:
@staticmethod
def tooltip(tip) -> None:
"""
write True or False in a file
Args:
@ -651,14 +656,14 @@ class FrameWidgets(ttk.Frame):
except subprocess.CalledProcessError:
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_
Args:
tunnel_name (str): name of tunnel
tunnel_name (str): name of a tunnel
Returns:
Dict[str, str]: dictionary with tunneldata
tuple[str, str]: tuple with tunnel data
"""
wg_read = f"/tmp/tlecdcwg/{tunnel_name}.conf"
@ -670,7 +675,7 @@ class FrameWidgets(ttk.Frame):
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.
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
"""
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)
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
@ -785,7 +791,8 @@ class FrameWidgets(ttk.Frame):
"""
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)
tl = Tunnel.list()
@ -839,11 +846,11 @@ class FrameWidgets(ttk.Frame):
def handle_connection_state(self, action: str, tunnel_name: str = None) -> None:
"""
Central management for connection states
central management for connection states
Args:
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 self.a: