From 6f02724daa35e7d4dcc07f52e26dae06d07d9a50 Mon Sep 17 00:00:00 2001 From: punix Date: Tue, 29 Apr 2025 09:02:06 +0200 Subject: [PATCH] with opening reduced --- wirepy.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/wirepy.py b/wirepy.py index 25fe1d7..b62cb6e 100755 --- a/wirepy.py +++ b/wirepy.py @@ -73,12 +73,12 @@ class Wirepy(tk.Tk): self.style = ttk.Style(self) self.tk.call("source", f"{tcl_path}/water.tcl") - with open(set_file, "r", encoding="utf-8") as read_file: - lines = read_file.readlines() - if "light\n" in lines: - self.tk.call("set_theme", "light") - else: - self.tk.call("set_theme", "dark") + + lines = set_file.read_text() + if "light\n" in lines: + self.tk.call("set_theme", "light") + else: + self.tk.call("set_theme", "dark") # Load the image file from the disk self.wg_icon = tk.PhotoImage(file=r"/usr/share/icons/lx-icons/48/wg_vpn.png") @@ -436,10 +436,8 @@ class FrameWidgets(ttk.Frame): self.l_box.delete(self.select_tunnel[0]) with open(set_file, "r", encoding="utf-8") as set_f6: lines6 = set_f6.readlines() - if ( - select_tl == lines6[7].strip() - and "off\n" not in lines6[7].strip() - ): + if (select_tl == lines6[7].strip() + and "off\n" not in lines6[7].strip()): lines6[7] = "off\n" with open(set_file, "w", encoding="utf-8") as set_f7: set_f7.writelines(lines6) @@ -805,14 +803,12 @@ class FrameWidgets(ttk.Frame): """ View activ Tunnel in the color green or yellow """ + lines = set_file.read_text() + if "light\n" in lines: + self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="green") - with open(set_file, "r", encoding="utf-8") as read_file: - lines = read_file.readlines() - if "light\n" in lines: - self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="green") - - else: - self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="yellow") + else: + self.lb_tunnel = ttk.Label(self, textvariable=self.str_var, foreground="yellow") self.lb_tunnel.config(font=("Ubuntu", 11, "bold")) self.lb_tunnel.grid(column=2, padx=10, row=1)