diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5f091cf..d102f44 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,7 @@
-
+
@@ -276,7 +276,15 @@
1725434328731
-
+
+
+ 1725475967338
+
+
+
+ 1725475967338
+
+
@@ -326,6 +334,7 @@
-
+
+
\ No newline at end of file
diff --git a/main.py b/main.py
index bf43e69..c0d9ae1 100755
--- a/main.py
+++ b/main.py
@@ -17,7 +17,7 @@ class MainWindow(tk.Tk):
self.switch_on = None
self.switch_off = None
self.x_width = 600
- self.y_height = 360
+ self.y_height = 340
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.resizable(width=False, height=False)
@@ -33,6 +33,13 @@ class MainWindow(tk.Tk):
# Set it as the window icon.
self.iconphoto(True, self.wg_icon)
+ # App Menu
+ self.app_menu = tk.Menu(self, borderwidth=0)
+ for item in self.app_menu.keys():
+ print(item, ': ', self.app_menu[item])
+ self.configure(menu=self.app_menu)
+ self.app_menu.add_cascade(label='?')
+
FrameWidgets(self).grid()
@@ -53,38 +60,46 @@ class FrameWidgets(ttk.Frame):
self.tr_pic = tk.PhotoImage(file=r'icons/wg-trash-48.png')
self.exp_pic = tk.PhotoImage(file=r'icons/wg-export-48.png')
self.warning_pic = tk.PhotoImage(file=r'icons/warning_64.png')
- self.configure()
# Show active Tunnel
self.a = TunnelActiv.active()
# Label Frame 1
self.lb_frame = ttk.Frame(self)
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=1, sticky='snew', padx=20, pady=5)
+ self.columnconfigure(2, weight=1)
+ self.rowconfigure(1, weight=1)
# Label Frame 2
self.lb_frame2 = ttk.Frame(self)
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=2, sticky='snew', padx=20, pady=5)
+ self.columnconfigure(2, weight=1)
+ self.rowconfigure(2, weight=1)
+ # Label Frame 3
+ self.lb_frame_buttons = ttk.Frame(self)
+ self.lb_frame_buttons.configure(relief='flat')
+ self.lb_frame_buttons.grid(column=0, rowspan=4, row=0)
+ self.columnconfigure(0, weight=1)
+ self.rowconfigure(0, weight=1)
# Show active Label
self.select_tunnel = None
self.lb = tk.Label(self, text='Active: ')
self.lb.config(font=('Ubuntu', 11, 'bold'))
- self.lb.grid(column=2, row=1, padx=15, sticky='w')
-
+ self.lb.grid(column=2, row=0, padx=15, sticky='w')
+ self.columnconfigure(2, weight=1)
+ self.rowconfigure(0, weight=1)
# Label to Show active Tunnel
self.StrVar = tk.StringVar(value=self.a)
GreenLabel.green_show_label(self)
# Interface Label
self.interface = tk.Label(self.lb_frame, text='Interface', fg=font_color)
- self.interface.grid(column=0, row=4, sticky='we', padx=120)
+ self.interface.grid(column=0, row=2, sticky='we', padx=120)
self.interface.config(font=('Ubuntu', 9))
# Peer Label
self.peer = tk.Label(self.lb_frame2, text='Peer', fg=font_color)
self.peer.config(font=('Ubuntu', 9))
- self.peer.grid(column=0, row=7, sticky='we', padx=130)
+ self.peer.grid(column=0, row=3, sticky='we', padx=130)
# Listbox with Scrollbar
def enable_check_box(event):
@@ -93,14 +108,16 @@ class FrameWidgets(ttk.Frame):
if len(tl) != 0:
self.wg_autostart.configure(state='normal')
- self.scrollbar = ttk.Scrollbar(self)
- self.l_box = tk.Listbox(self, fg='#606060', selectmode='single')
- self.l_box.config(highlightthickness=0, relief='flat')
- self.scrollbar.config(command=self.l_box.yview)
+ self.l_box = tk.Listbox(self.lb_frame_buttons, fg='#606060', selectmode='single')
+ self.l_box.config(highlightthickness=0, relief='ridge')
self.l_box.config(font=('Ubuntu', 12, 'bold'))
- self.l_box.grid(column=1, rowspan=3, row=1)
+ self.l_box.grid(column=1, rowspan=4, row=0, sticky='ns')
self.l_box.event_add('<>', '')
self.l_box.bind('<>', enable_check_box)
+ self.scrollbar = ttk.Scrollbar(self.lb_frame_buttons, orient='vertical', command=self.l_box.yview)
+ self.scrollbar.grid(column=1, rowspan=4, row=0, sticky='nse')
+ self.l_box.configure(yscrollcommand=self.scrollbar.set)
+ self.rowconfigure(0, weight=1)
# Tunnel List
self.tl = ListTunnels.tl_list()
@@ -126,8 +143,10 @@ class FrameWidgets(ttk.Frame):
ShowAddress.label_empty(self)
ShowAddress.show_data(self)
# Button Import
- self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=lambda: ImportTunnel.wg_import_select(self))
- self.btn_i.grid(column=0, row=2, padx=15, pady=15)
+ self.btn_i = tk.Button(self.lb_frame_buttons,
+ image=self.imp_pic, bd=0,
+ command=lambda: ImportTunnel.wg_import_select(self))
+ self.btn_i.grid(column=0, row=1, padx=15, pady=8)
def delete():
try:
@@ -154,25 +173,29 @@ class FrameWidgets(ttk.Frame):
del_tl = open('wg_py.xml', 'w')
del_tl.write(word_replace)
del_tl.close()
- if len(self.tl) == 0:
+ # for disable checkbox when Listbox empty
+ tl = ListTunnels.tl_list()
+ if len(tl) == 0:
self.wg_autostart.configure(state='disabled')
+
if self.a != '' and self.a == select_tl:
self.StrVar.set(value='')
StartStopBTN.button_start(self)
self.l_box.update()
# Address Label
ShowAddress.label_empty(self)
+
return select_tl
except IndexError:
pass
# Button Trash
- self.btn_tr = tk.Button(self, image=self.tr_pic, bd=0, command=delete)
- self.btn_tr.grid(column=0, row=3, padx=15, pady=15)
+ self.btn_tr = tk.Button(self.lb_frame_buttons, image=self.tr_pic, bd=0, command=delete)
+ self.btn_tr.grid(column=0, row=2, padx=15, pady=8)
# Button Export
- self.btn_exp = tk.Button(self, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
- self.btn_exp.grid(column=0, row=4, padx=15, pady=15)
+ self.btn_exp = tk.Button(self.lb_frame_buttons, image=self.exp_pic, bd=0, command=ExportTunnels.wg_export)
+ self.btn_exp.grid(column=0, row=3, padx=15, pady=8)
# Button Rename
self.btn_rename = ttk.Button(self, text='Rename')
@@ -185,7 +208,7 @@ class FrameWidgets(ttk.Frame):
text='Autoconnect on:',
variable=self.selected_option,
command=lambda: FileHandle.box_set(self))
- self.wg_autostart.grid(column=1, row=4, sticky='nw')
+ self.wg_autostart.grid(column=0, row=4, pady=19, padx=15, sticky='nw')
OnOff.on_off(self)
diff --git a/wg_func.py b/wg_func.py
index dab7940..2a0fe3b 100755
--- a/wg_func.py
+++ b/wg_func.py
@@ -2,7 +2,7 @@
import os
import shutil
from datetime import datetime
-from tkinter import filedialog
+from tkinter import filedialog, ttk
import tkinter as tk
font_color = '#4011a7'
@@ -41,30 +41,31 @@ class GreenLabel(tk.Tk):
def green_show_label(self):
self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
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=0)
self.columnconfigure(2, weight=1)
- self.rowconfigure(1, weight=1)
+ self.rowconfigure(0, weight=1)
class StartStopBTN(tk.Tk):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
+ self.lb_frame_buttons = None
self.wg_switch = None
self.btn_stst = None
self.wg_vpn_start = tk.PhotoImage(file=r'icons/wg-vpn-start-48.png')
self.wg_vpn_stop = tk.PhotoImage(file=r'icons/wg-vpn-stop-48.png')
def button_stop(self):
- self.btn_stst = tk.Button(self, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
- self.btn_stst.grid(column=0, row=1, padx=15, pady=10, sticky="s")
- self.columnconfigure(0, weight=1)
- self.rowconfigure(1, weight=1)
+ self.btn_stst = tk.Button(self.lb_frame_buttons, image=self.wg_vpn_stop, bd=0, command=self.wg_switch)
+ self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
+ #self.columnconfigure(0, weight=1)
+ #self.rowconfigure(0, weight=1)
def button_start(self):
- self.btn_stst = tk.Button(self, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
- self.btn_stst.grid(column=0, row=1, padx=15, pady=10, sticky="s")
- self.columnconfigure(0, weight=1)
- self.rowconfigure(1, weight=1)
+ self.btn_stst = tk.Button(self.lb_frame_buttons, image=self.wg_vpn_start, bd=0, command=self.wg_switch)
+ self.btn_stst.grid(column=0, row=0, padx=15, pady=8)
+ #self.columnconfigure(0, weight=1)
+ #self.rowconfigure(0, weight=1)
class ConToDict:
@@ -143,15 +144,15 @@ class ShowAddress(tk.Tk):
def show_data(self):
# Address Label
self.address = tk.Label(self.lb_frame, textvariable=self.add, fg='blue')
- self.address.grid(column=0, row=5, sticky='w', padx=10)
+ self.address.grid(column=0, row=4, sticky='w', padx=10, pady=6)
self.address.config(font=('Ubuntu', 9))
# DNS Label
self.dns = tk.Label(self.lb_frame, textvariable=self.DNS, fg='blue')
- self.dns.grid(column=0, row=6, sticky='w', padx=10, pady=3)
+ self.dns.grid(column=0, row=6, sticky='w', padx=10, pady=6)
self.dns.config(font=('Ubuntu', 9))
# Endpoint Label
self.endpoint = tk.Label(self.lb_frame2, textvariable=self.enp, fg='blue')
- self.endpoint.grid(column=0, row=8, sticky='w', padx=10, pady=5)
+ self.endpoint.grid(column=0, row=7, sticky='w', padx=10, pady=10)
self.endpoint.config(font=('Ubuntu', 9))
@@ -268,6 +269,7 @@ class FileHandle:
set_off = open('wg_py.xml', 'w')
set_off.write(word_replace)
set_off.close()
+
except IndexError:
self.selected_option.set(1)
@@ -277,6 +279,7 @@ class FileHandle:
class OnOff(tk.Tk, FileHandle):
def __init__(self, container, **kwargs):
super().__init__(container, **kwargs)
+ self.lb_frame_buttons = None
def on_off(self):
a_connect = {}
@@ -286,6 +289,7 @@ class OnOff(tk.Tk, FileHandle):
a_connect[line_splitted[0]] = line_splitted[1]
if 'true' in a_connect:
self.selected_option.set(1)
+ self.autoconnect_var.set('')
self.auto_con = a_connect['true']
else:
@@ -295,9 +299,9 @@ class OnOff(tk.Tk, FileHandle):
self.autoconnect_var = tk.StringVar()
self.autoconnect_var.set(self.auto_con)
- self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, bd=2, fg='blue', padx=5)
+ self.autoconnect = tk.Label(self, textvariable=self.autoconnect_var, fg='blue', padx=5)
self.autoconnect.config(font=('Ubuntu', 11))
- self.autoconnect.grid(column=1, row=4, sticky='we')
+ self.autoconnect.grid(column=0, row=4, sticky='ne', pady=20)
class ExportTunnels:
diff --git a/wg_py.xml b/wg_py.xml
index e69de29..2d98c87 100644
--- a/wg_py.xml
+++ b/wg_py.xml
@@ -0,0 +1,2 @@
+false peer_iasus
+false rverEppingen