methods optimized in wirepy and cls_mth_fc
This commit is contained in:
parent
6f02724daa
commit
213f772f40
Binary file not shown.
@ -135,8 +135,7 @@ class LxTools(tk.Tk):
|
|||||||
"""
|
"""
|
||||||
log_name: str = f"{Path.home()}"[6:]
|
log_name: str = f"{Path.home()}"[6:]
|
||||||
file: Path = Path.home() / "/tmp/.log_user"
|
file: Path = Path.home() / "/tmp/.log_user"
|
||||||
with open(file, "w", encoding="utf-8") as f:
|
Path(file).write_text(log_name, encoding="utf-8")
|
||||||
f.write(log_name)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_files(folder_path: Path = None, file: Path = None) -> None:
|
def clean_files(folder_path: Path = None, file: Path = None) -> None:
|
||||||
@ -156,9 +155,8 @@ class LxTools(tk.Tk):
|
|||||||
"""
|
"""
|
||||||
method that writes in file whether tooltip is displayed or not
|
method that writes in file whether tooltip is displayed or not
|
||||||
"""
|
"""
|
||||||
with open(path, "r", encoding="utf-8") as set_f2:
|
lines = Path(path).read_text(encoding="utf-8")
|
||||||
lines2 = set_f2.readlines()
|
if "False\n" in lines:
|
||||||
if "False\n" in lines2:
|
|
||||||
tip = False
|
tip = False
|
||||||
else:
|
else:
|
||||||
tip = True
|
tip = True
|
||||||
|
70
wirepy.py
70
wirepy.py
@ -349,11 +349,9 @@ class FrameWidgets(ttk.Frame):
|
|||||||
"""
|
"""
|
||||||
if self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
if self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
||||||
self.tk.call("set_theme", "light")
|
self.tk.call("set_theme", "light")
|
||||||
with open(set_file, "r", encoding="utf-8") as theme_set2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True) # (keepends=True) = not changed
|
||||||
lines3 = theme_set2.readlines()
|
lines[3] = 'light\n'
|
||||||
lines3[3] = "light\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as theme_set2:
|
|
||||||
theme_set2.writelines(lines3)
|
|
||||||
self.color_label()
|
self.color_label()
|
||||||
|
|
||||||
def theme_change_dark(self):
|
def theme_change_dark(self):
|
||||||
@ -362,33 +360,27 @@ class FrameWidgets(ttk.Frame):
|
|||||||
"""
|
"""
|
||||||
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
||||||
self.tk.call("set_theme", "dark")
|
self.tk.call("set_theme", "dark")
|
||||||
with open(set_file, "r", encoding="utf-8") as theme_set2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
lines4 = theme_set2.readlines()
|
lines[3] = 'dark\n'
|
||||||
lines4[3] = "dark\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as theme_set2:
|
|
||||||
theme_set2.writelines(lines4)
|
|
||||||
self.color_label()
|
self.color_label()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_setting(update_res):
|
def update_setting(update_res) -> None:
|
||||||
"""
|
"""
|
||||||
write off or on in file
|
write off or on in file
|
||||||
Args:
|
Args:
|
||||||
update_res (int): argument that is passed contains 0 or 1
|
update_res (int): argument that is passed contains 0 or 1
|
||||||
"""
|
"""
|
||||||
if update_res == 1:
|
if update_res == 1:
|
||||||
with open(set_file, "r", encoding="utf-8") as set_f2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
lines2 = set_f2.readlines()
|
lines[1] = 'off\n'
|
||||||
lines2[1] = "off\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as set_f2:
|
|
||||||
set_f2.writelines(lines2)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
with open(set_file, "r", encoding="utf-8") as set_f2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
lines2 = set_f2.readlines()
|
lines[1] = 'on\n'
|
||||||
lines2[1] = "on\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as set_f2:
|
|
||||||
set_f2.writelines(lines2)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tooltip(tip) -> None:
|
def tooltip(tip) -> None:
|
||||||
@ -398,20 +390,16 @@ class FrameWidgets(ttk.Frame):
|
|||||||
tip (bool): argument that is passed contains True or False
|
tip (bool): argument that is passed contains True or False
|
||||||
"""
|
"""
|
||||||
if tip:
|
if tip:
|
||||||
with open(set_file, "r", encoding="utf-8") as set_f2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
lines2 = set_f2.readlines()
|
lines[5] = 'False\n'
|
||||||
lines2[5] = "False\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as set_f2:
|
|
||||||
set_f2.writelines(lines2)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
with open(set_file, "r", encoding="utf-8") as set_f2:
|
lines = Path(set_file).read_text(encoding="utf-8").splitlines(keepends=True)
|
||||||
lines2 = set_f2.readlines()
|
lines[5] = 'True\n'
|
||||||
lines2[5] = "True\n"
|
Path(set_file).write_text(''.join(lines), encoding="utf-8")
|
||||||
with open(set_file, "w", encoding="utf-8") as set_f2:
|
|
||||||
set_f2.writelines(lines2)
|
|
||||||
|
|
||||||
def enable_check_box(self, _):
|
def enable_check_box(self, _) -> None:
|
||||||
"""
|
"""
|
||||||
checkbox for enable autostart Tunnel
|
checkbox for enable autostart Tunnel
|
||||||
"""
|
"""
|
||||||
@ -422,7 +410,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.lb_rename.delete(0, tk.END)
|
self.lb_rename.delete(0, tk.END)
|
||||||
self.btn_rename.config(state="normal")
|
self.btn_rename.config(state="normal")
|
||||||
|
|
||||||
def delete(self):
|
def delete(self) -> None:
|
||||||
"""
|
"""
|
||||||
delete Wireguard Tunnel
|
delete Wireguard Tunnel
|
||||||
"""
|
"""
|
||||||
@ -541,7 +529,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def import_sl(self):
|
def import_sl(self) -> None:
|
||||||
"""
|
"""
|
||||||
Import Methode for Wireguard config Files.
|
Import Methode for Wireguard config Files.
|
||||||
Before importing, it is checked whether PrivateKey and PublicKey are in the file.
|
Before importing, it is checked whether PrivateKey and PublicKey are in the file.
|
||||||
@ -671,7 +659,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.show_data()
|
self.show_data()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def box_set(self):
|
def box_set(self) -> None:
|
||||||
"""
|
"""
|
||||||
This Method will display the autostarted 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.
|
||||||
@ -705,7 +693,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
self.on_off()
|
self.on_off()
|
||||||
|
|
||||||
def on_off(self):
|
def on_off(self) -> None:
|
||||||
"""
|
"""
|
||||||
Here it is checked whether the path to the file is there, if not, it is created.
|
Here it is checked whether the path to the file is there, if not, it is created.
|
||||||
Set (on), the selected tunnel is displayed in the label.
|
Set (on), the selected tunnel is displayed in the label.
|
||||||
@ -732,7 +720,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.autoconnect.config(font=("Ubuntu", 11))
|
self.autoconnect.config(font=("Ubuntu", 11))
|
||||||
self.autoconnect.grid(column=1, row=0, sticky="e", pady=19)
|
self.autoconnect.grid(column=1, row=0, sticky="e", pady=19)
|
||||||
|
|
||||||
def init_and_report(self, data=None):
|
def init_and_report(self, data=None) -> None:
|
||||||
"""
|
"""
|
||||||
Displays the value address, DNS and peer in the labels
|
Displays the value address, DNS and peer in the labels
|
||||||
or empty it again
|
or empty it again
|
||||||
@ -755,7 +743,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
for field in fields:
|
for field in fields:
|
||||||
field.set("")
|
field.set("")
|
||||||
|
|
||||||
def show_data(self):
|
def show_data(self) -> None:
|
||||||
"""
|
"""
|
||||||
shows data in the label
|
shows data in the label
|
||||||
"""
|
"""
|
||||||
@ -775,7 +763,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.endpoint.grid(column=0, row=8, sticky="w", padx=10, pady=20)
|
self.endpoint.grid(column=0, row=8, sticky="w", padx=10, pady=20)
|
||||||
self.endpoint.config(font=("Ubuntu", 9))
|
self.endpoint.config(font=("Ubuntu", 9))
|
||||||
|
|
||||||
def stop(self):
|
def stop(self) -> None:
|
||||||
"""
|
"""
|
||||||
Stop Button
|
Stop Button
|
||||||
"""
|
"""
|
||||||
@ -785,7 +773,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
|
|
||||||
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
|
Tooltip(self.btn_stst, _("Click to stop selected Wireguard Tunnel"), tips)
|
||||||
|
|
||||||
def start(self):
|
def start(self) -> None:
|
||||||
"""
|
"""
|
||||||
Start Button
|
Start Button
|
||||||
"""
|
"""
|
||||||
@ -799,7 +787,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
else:
|
else:
|
||||||
Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), tips)
|
Tooltip(self.btn_stst, _("Click to start selected Wireguard Tunnel"), tips)
|
||||||
|
|
||||||
def color_label(self):
|
def color_label(self) -> None:
|
||||||
"""
|
"""
|
||||||
View activ Tunnel in the color green or yellow
|
View activ Tunnel in the color green or yellow
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user