small corrections
This commit is contained in:
parent
fecbf2ab46
commit
414a36b436
@ -148,14 +148,6 @@ class Tunnel:
|
|||||||
|
|
||||||
self.lb_tunnel.config(font=('Ubuntu', 11, 'bold'))
|
self.lb_tunnel.config(font=('Ubuntu', 11, 'bold'))
|
||||||
self.lb_tunnel.grid(column=2, padx=10, row=1)
|
self.lb_tunnel.grid(column=2, padx=10, row=1)
|
||||||
self.columnconfigure(2, weight=1)
|
|
||||||
self.rowconfigure(0, weight=1)
|
|
||||||
|
|
||||||
def columnconfigure(self, param, weight):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def rowconfigure(self, param, weight):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
36
wg_main.py
36
wg_main.py
@ -12,6 +12,7 @@ from wg_func import (Tunnel, FileHandle, OnOff, msg_window, WirePyUpdate, res, _
|
|||||||
|
|
||||||
tcl_path = Path('/usr/share/TK-Themes')
|
tcl_path = Path('/usr/share/TK-Themes')
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(tk.Tk):
|
class MainWindow(tk.Tk):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -29,7 +30,7 @@ class MainWindow(tk.Tk):
|
|||||||
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.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') '''
|
||||||
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:
|
||||||
@ -40,10 +41,10 @@ class MainWindow(tk.Tk):
|
|||||||
''' Load the image file from disk. '''
|
''' Load the image file from disk. '''
|
||||||
self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png')
|
self.wg_icon = tk.PhotoImage(file=r'/usr/share/icons/wp-icons/48/wg_vpn.png')
|
||||||
|
|
||||||
# Set it as the window icon.
|
''' Set it as the window icon '''
|
||||||
self.iconphoto(True, self.wg_icon)
|
self.iconphoto(True, self.wg_icon)
|
||||||
|
|
||||||
#Set on or off in file
|
''' Set on or off in file '''
|
||||||
def update():
|
def update():
|
||||||
if set_update.get() == 1:
|
if set_update.get() == 1:
|
||||||
with open(path_to_file2, 'r') as set_file2:
|
with open(path_to_file2, 'r') as set_file2:
|
||||||
@ -59,10 +60,9 @@ 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 on or off in file '''
|
||||||
def tooltip():
|
def tooltip():
|
||||||
if set_tip.get():
|
if set_tip.get():
|
||||||
print(set_tip.get())
|
|
||||||
with open(path_to_file2, 'r') as set_file2:
|
with open(path_to_file2, 'r') as set_file2:
|
||||||
lines2 = set_file2.readlines()
|
lines2 = set_file2.readlines()
|
||||||
lines2[5] = 'False\n'
|
lines2[5] = 'False\n'
|
||||||
@ -76,10 +76,10 @@ 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 dark or light
|
''' Set dark or light '''
|
||||||
def theme_change_light():
|
def theme_change_light():
|
||||||
if self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
if self.tk.call("ttk::style", "theme", "use") == "water-dark":
|
||||||
# Set light theme
|
''' Set light theme '''
|
||||||
self.tk.call('set_theme', 'light')
|
self.tk.call('set_theme', 'light')
|
||||||
with open(path_to_file2, 'r') as theme_set2:
|
with open(path_to_file2, 'r') as theme_set2:
|
||||||
lines3 = theme_set2.readlines()
|
lines3 = theme_set2.readlines()
|
||||||
@ -89,7 +89,7 @@ class MainWindow(tk.Tk):
|
|||||||
|
|
||||||
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":
|
||||||
# Set dark theme
|
''' Set dark theme '''
|
||||||
self.tk.call('set_theme', 'dark')
|
self.tk.call('set_theme', 'dark')
|
||||||
with open(path_to_file2, 'r') as theme_set2:
|
with open(path_to_file2, 'r') as theme_set2:
|
||||||
lines4 = theme_set2.readlines()
|
lines4 = theme_set2.readlines()
|
||||||
@ -123,7 +123,7 @@ class MainWindow(tk.Tk):
|
|||||||
self.columnconfigure(0, weight=1)
|
self.columnconfigure(0, weight=1)
|
||||||
self.rowconfigure(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, padx=10)
|
||||||
@ -303,7 +303,6 @@ class StSt:
|
|||||||
self.btn_stst.bind('<Leave>', start_leave)
|
self.btn_stst.bind('<Leave>', start_leave)
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
|
||||||
class TLImp:
|
class TLImp:
|
||||||
"""
|
"""
|
||||||
Import Class for Wireguard config Files.
|
Import Class for Wireguard config Files.
|
||||||
@ -444,7 +443,6 @@ class TLImp:
|
|||||||
''' Remove Tool-Tip '''
|
''' Remove Tool-Tip '''
|
||||||
window.my_tool_tip.destroy()
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
|
|
||||||
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
||||||
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
||||||
self.l_box.bind('<Enter>', list_info_enter)
|
self.l_box.bind('<Enter>', list_info_enter)
|
||||||
@ -470,7 +468,6 @@ class TLImp:
|
|||||||
check_call(['nmcli', 'con', 'mod', self.a, 'connection.autoconnect', 'no'])
|
check_call(['nmcli', 'con', 'mod', self.a, 'connection.autoconnect', 'no'])
|
||||||
Path.chmod(wg_read, 0o600)
|
Path.chmod(wg_read, 0o600)
|
||||||
|
|
||||||
|
|
||||||
if 'PrivateKey = ' and 'Endpoint = ' not in read:
|
if 'PrivateKey = ' and 'Endpoint = ' not in read:
|
||||||
"""img_w, img_i, w_title, w_txt hand over"""
|
"""img_w, img_i, w_title, w_txt hand over"""
|
||||||
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
iw = r'/usr/share/icons/wp-icons/64/error.png'
|
||||||
@ -490,7 +487,6 @@ class TLImp:
|
|||||||
print('Tunnel exist!')
|
print('Tunnel exist!')
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyTypeChecker
|
|
||||||
class FrameWidgets(ttk.Frame):
|
class FrameWidgets(ttk.Frame):
|
||||||
def __init__(self, container, **kwargs):
|
def __init__(self, container, **kwargs):
|
||||||
super().__init__(container, **kwargs)
|
super().__init__(container, **kwargs)
|
||||||
@ -567,7 +563,6 @@ 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')
|
||||||
|
|
||||||
|
|
||||||
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, selectmode='single')
|
self.l_box = tk.Listbox(self.lb_frame_btn_lbox, selectmode='single')
|
||||||
self.l_box.config(relief='ridge', font=('Ubuntu', 12, 'bold'))
|
self.l_box.config(relief='ridge', font=('Ubuntu', 12, 'bold'))
|
||||||
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
|
self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
|
||||||
@ -610,7 +605,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.l_box.bind('<Enter>', list_not_empty_enter)
|
self.l_box.bind('<Enter>', list_not_empty_enter)
|
||||||
self.l_box.bind('<Leave>', list_not_empty_leave)
|
self.l_box.bind('<Leave>', list_not_empty_leave)
|
||||||
|
|
||||||
|
|
||||||
''' Button Vpn '''
|
''' Button Vpn '''
|
||||||
if self.a != '':
|
if self.a != '':
|
||||||
StSt.stop(self)
|
StSt.stop(self)
|
||||||
@ -662,7 +656,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.l_box.delete(self.select_tunnel[0])
|
self.l_box.delete(self.select_tunnel[0])
|
||||||
with open(path_to_file2, 'r') as set_file6:
|
with open(path_to_file2, 'r') as set_file6:
|
||||||
lines6 = set_file6.readlines()
|
lines6 = set_file6.readlines()
|
||||||
if select_tl == lines6[7].strip() and not 'off' in lines6[7].strip():
|
if select_tl == lines6[7].strip() and 'off' not in lines6[7].strip():
|
||||||
lines6[7] = 'off'
|
lines6[7] = 'off'
|
||||||
with open(path_to_file2, 'w') as set_file7:
|
with open(path_to_file2, 'w') as set_file7:
|
||||||
set_file7.writelines(lines6)
|
set_file7.writelines(lines6)
|
||||||
@ -681,6 +675,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.wg_autostart.configure(state='disabled')
|
self.wg_autostart.configure(state='disabled')
|
||||||
|
|
||||||
''' for disable checkbox when Listbox empty '''
|
''' for disable checkbox when Listbox empty '''
|
||||||
|
|
||||||
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,
|
||||||
@ -775,6 +770,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
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,
|
||||||
@ -834,6 +830,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
else:
|
else:
|
||||||
self.lb_rename.bind('<Enter>', rename_no_active_enter)
|
self.lb_rename.bind('<Enter>', rename_no_active_enter)
|
||||||
self.lb_rename.bind('<Leave>', rename_no_active_leave)
|
self.lb_rename.bind('<Leave>', rename_no_active_leave)
|
||||||
|
|
||||||
def tl_rename():
|
def tl_rename():
|
||||||
special_characters = ['\\', '/', '{', '}', ' ']
|
special_characters = ['\\', '/', '{', '}', ' ']
|
||||||
|
|
||||||
@ -885,7 +882,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.StrVar.set(value=self.a)
|
self.StrVar.set(value=self.a)
|
||||||
with open(path_to_file2, 'r') as set_file5:
|
with open(path_to_file2, 'r') as set_file5:
|
||||||
lines5 = set_file5.readlines()
|
lines5 = set_file5.readlines()
|
||||||
if select_tl == lines5[7].strip() and not 'off' in lines5[7].strip():
|
if select_tl == lines5[7].strip() and 'off' not in lines5[7].strip():
|
||||||
lines5[7] = new_a_connect
|
lines5[7] = new_a_connect
|
||||||
with open(path_to_file2, 'w') as theme_set5:
|
with open(path_to_file2, 'w') as theme_set5:
|
||||||
theme_set5.writelines(lines5)
|
theme_set5.writelines(lines5)
|
||||||
@ -907,7 +904,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
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=2, row=4, padx=20, pady=15, 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()
|
||||||
@ -921,6 +917,7 @@ class FrameWidgets(ttk.Frame):
|
|||||||
variable=self.selected_option,
|
variable=self.selected_option,
|
||||||
command=lambda: FileHandle.box_set(self))
|
command=lambda: FileHandle.box_set(self))
|
||||||
self.wg_autostart.grid(column=0, row=4, pady=15, padx=15, sticky='nw')
|
self.wg_autostart.grid(column=0, row=4, 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 """
|
||||||
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
window.my_tool_tip = MyToolTip(event.x_root, event.y_root,
|
||||||
@ -933,7 +930,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
window.my_tool_tip.destroy()
|
window.my_tool_tip.destroy()
|
||||||
|
|
||||||
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
if self.l_box.size() >= 1 and len(self.l_box.curselection()) >= 1:
|
||||||
|
|
||||||
def chk_a_enter(event):
|
def chk_a_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,
|
||||||
@ -947,7 +943,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
||||||
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
||||||
|
|
||||||
|
|
||||||
if self.l_box.size() == 0:
|
if self.l_box.size() == 0:
|
||||||
self.wg_autostart.bind('<Enter>', chk_enter)
|
self.wg_autostart.bind('<Enter>', chk_enter)
|
||||||
self.wg_autostart.bind('<Leave>', chk_leave)
|
self.wg_autostart.bind('<Leave>', chk_leave)
|
||||||
@ -965,7 +960,6 @@ class FrameWidgets(ttk.Frame):
|
|||||||
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
self.wg_autostart.bind('<Enter>', chk_a_enter)
|
||||||
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
self.wg_autostart.bind('<Leave>', chk_a_leave)
|
||||||
|
|
||||||
|
|
||||||
OnOff.on_off(self)
|
OnOff.on_off(self)
|
||||||
|
|
||||||
def wg_switch(self):
|
def wg_switch(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user