Merge pull request '1.11.0824' (#23) from 1.11.0824 into main

Reviewed-on: https://git.ilunix.de/punix/Wire-Py/pulls/23
This commit is contained in:
Désiré Werner Menrath 2024-11-08 21:24:31 +01:00
commit 03a7e48018
2 changed files with 99 additions and 106 deletions

View File

@ -11,6 +11,20 @@ My standard System: Linux Mint 22 Cinnamon
### Added ### Added
07-11-2024 07-11-2024
- remove classes and add methods to class FrameWidgets (removed self errors)
### Added
08-11-2024
- methods from class MainWindow move to class FrameWidgets for active color_label when theme change
- optimize columnconfigure, rowconfigure in class MainWindow and FrameWidgets
- add new Frame for Widgets on Bottom
- optimize from tkinter * to from tkinter import filedialog, ttk, TclError
### Added
07-11-2024
- remove classes and add methods to class FrameWidgets (removed self errors) - remove classes and add methods to class FrameWidgets (removed self errors)

View File

@ -5,8 +5,7 @@ import subprocess
import tkinter as tk import tkinter as tk
from pathlib import Path from pathlib import Path
from subprocess import check_call from subprocess import check_call
from tkinter import * from tkinter import filedialog, ttk, TclError
from tkinter import filedialog, ttk
from wg_func import (Tunnel, msg_window, WirePyUpdate, res, _u, version, path_to_file2, tips) from wg_func import (Tunnel, msg_window, WirePyUpdate, res, _u, version, path_to_file2, tips)
@ -19,15 +18,16 @@ class MainWindow(tk.Tk):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.my_tool_tip = None self.my_tool_tip = None
self.switch_on = None
self.switch_off = None
self.x_width = 600 self.x_width = 600
self.y_height = 400 self.y_height = 383
self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2) self.monitor_center_x = self.winfo_screenwidth() / 2 - (self.x_width / 2)
self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2) self.monitor_center_y = self.winfo_screenheight() / 2 - (self.y_height / 2)
self.resizable(width=False, height=False) self.resizable(width=True, height=True)
self.title('Wire-Py') self.title('Wire-Py')
self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y)) self.geometry('%dx%d+%d+%d' % (self.x_width, self.y_height, self.monitor_center_x, self.monitor_center_y))
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
self.style = ttk.Style(self) self.style = ttk.Style(self)
self.tk.call('source', str(tcl_path) + '/water.tcl') self.tk.call('source', str(tcl_path) + '/water.tcl')
''' self.tk.call('source', 'TK-Themes/water.tcl') ''' ''' self.tk.call('source', 'TK-Themes/water.tcl') '''
@ -44,6 +44,28 @@ class MainWindow(tk.Tk):
''' Set it as the window icon ''' ''' Set it as the window icon '''
self.iconphoto(True, self.wg_icon) self.iconphoto(True, self.wg_icon)
FrameWidgets(self).grid()
class FrameWidgets(ttk.Frame):
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.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
self.imp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_import.png')
self.tr_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_trash.png')
self.exp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_export.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
''' Set on or off in file ''' ''' Set on or off in file '''
def update(): def update():
@ -61,7 +83,7 @@ class MainWindow(tk.Tk):
with open(path_to_file2, 'w') as set_file2: with open(path_to_file2, 'w') as set_file2:
set_file2.writelines(lines2) set_file2.writelines(lines2)
''' Set on or off in file ''' ''' Set True or False in file '''
def tooltip(): def tooltip():
if set_tip.get(): if set_tip.get():
@ -89,6 +111,7 @@ class MainWindow(tk.Tk):
lines3[3] = 'light\n' lines3[3] = 'light\n'
with open(path_to_file2, 'w') as theme_set2: with open(path_to_file2, 'w') as theme_set2:
theme_set2.writelines(lines3) theme_set2.writelines(lines3)
self.color_label()
def theme_change_dark(): def theme_change_dark():
if not self.tk.call("ttk::style", "theme", "use") == "water-dark": if not self.tk.call("ttk::style", "theme", "use") == "water-dark":
@ -99,6 +122,7 @@ class MainWindow(tk.Tk):
lines4[3] = 'dark\n' lines4[3] = 'dark\n'
with open(path_to_file2, 'w') as theme_set2: with open(path_to_file2, 'w') as theme_set2:
theme_set2.writelines(lines4) theme_set2.writelines(lines4)
self.color_label()
def info(): def info():
def link_btn(): def link_btn():
@ -122,14 +146,12 @@ class MainWindow(tk.Tk):
''' Frame for Menu ''' ''' Frame for Menu '''
self.menu_frame = ttk.Frame(self) self.menu_frame = ttk.Frame(self)
self.menu_frame.configure(relief='flat') self.menu_frame.configure(relief='flat')
self.menu_frame.grid(column=0, row=0, sticky='w') self.menu_frame.grid(column=0, row=0, columnspan=4, sticky='w')
self.columnconfigure(0, weight=1)
self.rowconfigure(0, weight=1)
''' App Menu ''' ''' App Menu '''
self.version_lb = ttk.Label(self.menu_frame, text=version) self.version_lb = ttk.Label(self.menu_frame, text=version)
self.version_lb.config(font=('Ubuntu', 11), foreground='#00c4ff') self.version_lb.config(font=('Ubuntu', 11), foreground='#00c4ff')
self.version_lb.grid(column=0, row=0, padx=10) self.version_lb.grid(column=0, row=0, rowspan=4, padx=10)
def version_enter(event): def version_enter(event):
""" The mouse moves into the Version widget """ """ The mouse moves into the Version widget """
@ -169,13 +191,11 @@ class MainWindow(tk.Tk):
''' About BTN Menu / Label ''' ''' About BTN Menu / Label '''
self.about_btn = ttk.Button(self.menu_frame, text='About', style='Toolbutton', command=info) self.about_btn = ttk.Button(self.menu_frame, text='About', style='Toolbutton', command=info)
self.about_btn.grid(column=2, row=0) self.about_btn.grid(column=2, row=0)
self.readme = tk.Menu(self) self.readme = tk.Menu(self)
''' Update and Tooltip Label ''' ''' Update and Tooltip Label '''
self.updates_lb = ttk.Label(self.menu_frame) self.updates_lb = ttk.Label(self.menu_frame)
self.updates_lb.grid(column=3, row=0, padx=10) self.updates_lb.grid(column=3, row=0, padx=10)
'''View Checkbox for enable or disable Tooltip ''' '''View Checkbox for enable or disable Tooltip '''
if tips: if tips:
set_tip.set(value=False) set_tip.set(value=False)
@ -225,8 +245,7 @@ class MainWindow(tk.Tk):
def download_enter(event): def download_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click to download new version')
'Click to download new version')
def download_leave(_): def download_leave(_):
""" The mouse moves from the entry widget """ """ The mouse moves from the entry widget """
@ -240,35 +259,6 @@ class MainWindow(tk.Tk):
self.update_btn.configure(menu=self.download, style='Toolbutton') self.update_btn.configure(menu=self.download, style='Toolbutton')
self.download.add_command(label='Download', command=WirePyUpdate.download) self.download.add_command(label='Download', command=WirePyUpdate.download)
FrameWidgets(self).grid()
class FrameWidgets(ttk.Frame):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
self.endpoint = None
self.dns = None
self.address = None
self.btn_stst = None
self.auto_con = None
self.enp = None
self.DNS = None
self.add = None
self.data = None
self.peer = None
self.lb_tunnel = None
self.wg_read = None
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
self.imp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_import.png')
self.tr_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_trash.png')
self.exp_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_export.png')
self.warning_pic = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/64/error.png')
self.wg_vpn_start = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-start.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn-stop.png')
''' Show active Tunnel ''' ''' Show active Tunnel '''
self.a = Tunnel.active() self.a = Tunnel.active()
@ -276,30 +266,27 @@ class FrameWidgets(ttk.Frame):
self.lb_frame_btn_lbox = ttk.Frame(self) self.lb_frame_btn_lbox = ttk.Frame(self)
self.lb_frame_btn_lbox.configure(relief='flat') self.lb_frame_btn_lbox.configure(relief='flat')
self.lb_frame_btn_lbox.grid(column=0, rowspan=3, row=1) self.lb_frame_btn_lbox.grid(column=0, rowspan=3, row=1)
self.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1)
''' Label Frame 2 ''' ''' Label Frame 2 '''
self.lb_frame = ttk.Frame(self) self.lb_frame = ttk.Frame(self)
self.lb_frame.configure(relief='solid') self.lb_frame.configure(relief='solid')
self.lb_frame.grid(column=2, row=2, sticky='snew', padx=20, pady=5) self.lb_frame.grid(column=2, row=2, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(2, weight=1)
''' Label Frame 3 ''' ''' Label Frame 3 '''
self.lb_frame2 = ttk.Frame(self) self.lb_frame2 = ttk.Frame(self)
self.lb_frame2.configure(relief='solid') self.lb_frame2.configure(relief='solid')
self.lb_frame2.grid(column=2, row=3, sticky='snew', padx=20, pady=5) self.lb_frame2.grid(column=2, row=3, sticky='snew', padx=20, pady=5)
self.columnconfigure(2, weight=1)
self.rowconfigure(3, weight=1) ''' Bottom Frame 4 '''
self.lb_frame3 = ttk.Frame(self)
self.lb_frame3.configure(relief='flat')
self.lb_frame3.grid(column=0, row=5, columnspan=4, sticky='snew', padx=2, pady=2)
''' Show active Label ''' ''' Show active Label '''
self.select_tunnel = None self.select_tunnel = None
self.lb = ttk.Label(self, text='Active: ') self.lb = ttk.Label(self, text='Active: ')
self.lb.config(font=('Ubuntu', 11, 'bold')) self.lb.config(font=('Ubuntu', 11, 'bold'))
self.lb.grid(column=2, row=1, padx=15, pady=4, sticky='w') self.lb.grid(column=2, row=1, padx=15, pady=4, sticky='w')
self.columnconfigure(2, weight=1)
self.rowconfigure(0, weight=1)
''' Label to Show active Tunnel ''' ''' Label to Show active Tunnel '''
self.StrVar = tk.StringVar(value=self.a) self.StrVar = tk.StringVar(value=self.a)
@ -333,7 +320,6 @@ class FrameWidgets(ttk.Frame):
self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview) self.scrollbar = ttk.Scrollbar(self.lb_frame_btn_lbox, orient='vertical', command=self.l_box.yview)
self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse') self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse')
self.l_box.configure(yscrollcommand=self.scrollbar.set) self.l_box.configure(yscrollcommand=self.scrollbar.set)
self.rowconfigure(0, weight=1)
''' Tunnel List ''' ''' Tunnel List '''
self.tl = Tunnel.list() self.tl = Tunnel.list()
@ -388,15 +374,12 @@ class FrameWidgets(ttk.Frame):
self.show_data() self.show_data()
''' Button Import ''' ''' Button Import '''
self.btn_i = ttk.Button(self.lb_frame_btn_lbox, self.btn_i = ttk.Button(self.lb_frame_btn_lbox, image=self.imp_pic, command=self.import_sl, padding=0)
image=self.imp_pic, command=self.import_sl,
padding=0)
self.btn_i.grid(column=0, row=1, padx=15, pady=8) self.btn_i.grid(column=0, row=1, padx=15, pady=8)
def imp_enter(event): def imp_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'Click to import a Wireguard Tunnel')
'Click to import a Wireguard Tunnel')
def imp_leave(_): def imp_leave(_):
""" The mouse moves from the entry widget """ """ The mouse moves from the entry widget """
@ -503,8 +486,7 @@ class FrameWidgets(ttk.Frame):
def empty_list_enter(event): def empty_list_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No tunnels to delete in the list')
'No tunnels to delete in the list')
def empty_list_leave(_): def empty_list_leave(_):
""" The mouse moves from the entry widget """ """ The mouse moves from the entry widget """
@ -529,14 +511,12 @@ class FrameWidgets(ttk.Frame):
self.btn_tr.bind('<Leave>', del_leave) self.btn_tr.bind('<Leave>', del_leave)
''' Button Export ''' ''' Button Export '''
self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export, self.btn_exp = ttk.Button(self.lb_frame_btn_lbox, image=self.exp_pic, command=Tunnel.export, padding=0)
padding=0)
self.btn_exp.grid(column=0, row=3, padx=15, pady=8) self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
def empty_list_enter(event): def empty_list_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No Tunnels in List for Export')
'No Tunnels in List for Export')
def empty_list_leave(_): def empty_list_leave(_):
""" The mouse moves from the entry widget """ """ The mouse moves from the entry widget """
@ -561,8 +541,8 @@ class FrameWidgets(ttk.Frame):
self.btn_exp.bind('<Leave>', exp_leave) self.btn_exp.bind('<Leave>', exp_leave)
''' Label Entry ''' ''' Label Entry '''
self.lb_rename = ttk.Entry(self, width=20) self.lb_rename = ttk.Entry(self.lb_frame3, width=20)
self.lb_rename.grid(column=2, row=4, padx=30, pady=15, sticky='nw') self.lb_rename.grid(column=2, row=0, padx=8, pady=10, sticky='ne')
self.lb_rename.insert(0, 'Max. 12 characters!') self.lb_rename.insert(0, 'Max. 12 characters!')
self.lb_rename.config(state='disable') self.lb_rename.config(state='disable')
@ -662,21 +642,21 @@ class FrameWidgets(ttk.Frame):
msg_window(iw, ii, wt, msg_t) msg_window(iw, ii, wt, msg_t)
''' Button Rename ''' ''' Button Rename '''
self.btn_rename = ttk.Button(self, text='Rename', state='disable', command=tl_rename, padding=4, self.btn_rename = ttk.Button(self.lb_frame3, text='Rename', state='disable', command=tl_rename, padding=4,
style='RnButton.TButton') style='RnButton.TButton')
self.btn_rename.grid(column=2, row=4, padx=20, pady=15, 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(self.auto_con)
''' Frame for Labels, Entry and Button''' ''' Frame for Labels, Entry and Button'''
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var) self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, width=15)
self.autoconnect.config(font=('Ubuntu', 11)) self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', padx=10, pady=15) self.autoconnect.grid(column=1, row=0, sticky='e', pady=19)
self.wg_autostart = ttk.Checkbutton(self, text='Autoconnect on:', variable=self.selected_option, self.wg_autostart = ttk.Checkbutton(self.lb_frame3, text='Autoconnect on:', variable=self.selected_option,
command=self.box_set) command=self.box_set)
self.wg_autostart.grid(column=0, row=4, pady=15, padx=15, sticky='nw') self.wg_autostart.grid(column=0, row=0, pady=15, padx=15, sticky='nw')
def chk_enter(event): def chk_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
@ -722,6 +702,7 @@ class FrameWidgets(ttk.Frame):
self.on_off() self.on_off()
def import_sl(self):
""" """
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.
@ -732,9 +713,6 @@ class FrameWidgets(ttk.Frame):
If True then the name is automatically shortened to 12 characters and then imported. If True then the name is automatically shortened to 12 characters and then imported.
If in each case false comes out, a corresponding window comes to inform the user that something is wrong. If in each case false comes out, a corresponding window comes to inform the user that something is wrong.
""" """
def import_sl(self):
try: try:
filepath = filedialog.askopenfilename(initialdir=str(_u), title='Select Wireguard config File', filepath = filedialog.askopenfilename(initialdir=str(_u), title='Select Wireguard config File',
filetypes=[('WG config files', '*.conf')], ) filetypes=[('WG config files', '*.conf')], )
@ -890,14 +868,12 @@ class FrameWidgets(ttk.Frame):
print('Tunnel exist!') print('Tunnel exist!')
''' def box_set(self):
"""
This Method will display the autostart label which This Method will display the autostart 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.
''' """
def box_set(self):
try: try:
select_tunnel = self.l_box.curselection() select_tunnel = self.l_box.curselection()
select_tl = self.l_box.get(select_tunnel[0]) select_tl = self.l_box.get(select_tunnel[0])
@ -926,13 +902,12 @@ class FrameWidgets(ttk.Frame):
self.on_off() self.on_off()
''' def on_off(self):
"""
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.
At (off) the label is first emptied then filled with No Autoconnect At (off) the label is first emptied then filled with No Autoconnect
''' """
def on_off(self):
with open(path_to_file2, 'r') as set_file4: with open(path_to_file2, 'r') as set_file4:
lines4 = set_file4.readlines() lines4 = set_file4.readlines()
@ -949,16 +924,16 @@ class FrameWidgets(ttk.Frame):
self.autoconnect_var = tk.StringVar() self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con) self.autoconnect_var.set(self.auto_con)
self.autoconnect = ttk.Label(self, textvariable=self.autoconnect_var, foreground='#0071ff') self.autoconnect = ttk.Label(self.lb_frame3, textvariable=self.autoconnect_var, foreground='#0071ff', width=15)
self.autoconnect.config(font=('Ubuntu', 11)) self.autoconnect.config(font=('Ubuntu', 11))
self.autoconnect.grid(column=0, row=4, sticky='ne', pady=19) self.autoconnect.grid(column=1, row=0, sticky='e', pady=19)
def init_and_report(self, data=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
""" """
def init_and_report(self, data=None):
""" Address Label """ """ Address Label """
self.add = tk.StringVar() self.add = tk.StringVar()
self.add.set('Address: ' + data[0]) self.add.set('Address: ' + data[0])
@ -989,6 +964,7 @@ class FrameWidgets(ttk.Frame):
self.endpoint.config(font=('Ubuntu', 9)) self.endpoint.config(font=('Ubuntu', 9))
def stop(self): def stop(self):
""" Stop Button """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, command=self.wg_switch, padding=0) self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_stop, command=self.wg_switch, 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)
@ -1006,13 +982,13 @@ class FrameWidgets(ttk.Frame):
self.btn_stst.bind('<Leave>', stop_leave) self.btn_stst.bind('<Leave>', stop_leave)
def start(self): def start(self):
""" Start Button """
self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=self.wg_switch, padding=0) self.btn_stst = ttk.Button(self.lb_frame_btn_lbox, image=self.wg_vpn_start, command=self.wg_switch, 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)
def empty_list_start_enter(event): def empty_list_start_enter(event):
""" The mouse moves into the entry widget """ """ The mouse moves into the entry widget """
window.my_tool_tip = MyToolTip(event.x_root, event.y_root, window.my_tool_tip = MyToolTip(event.x_root, event.y_root, 'No tunnels to start in the list')
'No tunnels to start in the list')
def empty_list_start_leave(_): def empty_list_start_leave(_):
""" The mouse moves from the entry widget """ """ The mouse moves from the entry widget """
@ -1038,6 +1014,8 @@ class FrameWidgets(ttk.Frame):
self.btn_stst.bind('<Leave>', start_leave) self.btn_stst.bind('<Leave>', start_leave)
def color_label(self): def color_label(self):
""" View activ Tunnel in color green or yellow """
with open(path_to_file2, 'r') as read_file: with open(path_to_file2, 'r') as read_file:
lines = read_file.readlines() lines = read_file.readlines()
if 'light\n' in lines: if 'light\n' in lines:
@ -1050,6 +1028,7 @@ class FrameWidgets(ttk.Frame):
self.lb_tunnel.grid(column=2, padx=10, row=1) self.lb_tunnel.grid(column=2, padx=10, row=1)
def wg_switch(self): def wg_switch(self):
self.a = Tunnel.active() self.a = Tunnel.active()
try: try:
if self.a == '': if self.a == '':