diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index aa0bbdc..433002f 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,10 @@
-
+
+
@@ -186,7 +187,15 @@
1724400463791
-
+
+
+ 1724401340512
+
+
+
+ 1724401340512
+
+
@@ -225,6 +234,7 @@
-
+
+
\ No newline at end of file
diff --git a/main.py b/main.py
index a339846..9a5e9dd 100644
--- a/main.py
+++ b/main.py
@@ -103,12 +103,7 @@ class FrameWidgets(ttk.Frame):
file = open(wg_read, 'r')
data = ConToDict.covert_to_dict(file)
# Address Label
- self.add = tk.StringVar()
- self.add.set('Address: ' + data[0])
- self.DNS = tk.StringVar()
- self.DNS.set(' DNS: ' + data[1])
- self.enp = tk.StringVar()
- self.enp.set('Endpoint: ' + data[2])
+ ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
file.close()
else:
@@ -117,9 +112,7 @@ class FrameWidgets(ttk.Frame):
self.add = tk.StringVar()
self.DNS = tk.StringVar()
self.enp = tk.StringVar()
- self.add.set('')
- self.DNS.set('')
- self.enp.set('')
+ 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))
@@ -136,11 +129,8 @@ class FrameWidgets(ttk.Frame):
StartStopBTN.button_start(self)
self.l_box.update()
# Address Label
- self.add.set('')
- self.DNS.set('')
- self.enp.set('')
+ ShowAddress.label_empty(self)
ShowAddress.show_data(self)
-
# 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)
@@ -164,12 +154,7 @@ class FrameWidgets(ttk.Frame):
file = open(wg_read, 'r')
data = ConToDict.covert_to_dict(file)
# Address Label
- self.add = tk.StringVar()
- self.add.set('Address: ' + data[0])
- self.DNS = tk.StringVar()
- self.DNS.set(' DNS: ' + data[1])
- self.enp = tk.StringVar()
- self.enp.set('Endpoint: ' + data[2])
+ ShowAddress.init_and_report(self, data)
ShowAddress.show_data(self)
file.close()
# Button Start/Stop
@@ -188,9 +173,7 @@ class FrameWidgets(ttk.Frame):
self.StrVar.set('')
GreenLabel.green_show_label(self)
# Address Label
- self.add.set('')
- self.DNS.set('')
- self.enp.set('')
+ ShowAddress.label_empty(self)
ShowAddress.show_data(self)
diff --git a/wg_func.py b/wg_func.py
index 6ccf144..f5800c6 100644
--- a/wg_func.py
+++ b/wg_func.py
@@ -74,7 +74,7 @@ class ConToDict:
for items in dictlist:
if items == '=':
dictlist.remove(items)
- for i in dictlist: # Here is the beginning (Loop) of convert List to Dictionary
+ for i in dictlist: # Here is the beginning (Loop) of convert List to Dictionary
a = [dictlist[0], dictlist[1]]
b = [dictlist[2], dictlist[3]]
c = [dictlist[4], dictlist[5]]
@@ -118,6 +118,20 @@ class ShowAddress(tk.Tk):
self.DNS = None
self.add = None
+ def init_and_report(self, data=None):
+ # Address Label
+ self.add = tk.StringVar()
+ self.add.set('Address: ' + data[0])
+ self.DNS = tk.StringVar()
+ self.DNS.set(' DNS: ' + data[1])
+ self.enp = tk.StringVar()
+ self.enp.set('Endpoint: ' + data[2])
+
+ def label_empty(self):
+ self.add.set('')
+ self.DNS.set('')
+ self.enp.set('')
+
def show_data(self):
# Address Label
self.address = tk.Label(self.lb_frame, textvariable=self.add, fg='blue')