diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]/shelved.patch
new file mode 100644
index 0000000..99be84b
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]/shelved.patch
@@ -0,0 +1,76 @@
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\n\n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n {\n "associatedIndex": 3\n} \n \n \n \n \n \n \n \n \n {\n "keyToString": {\n "ASKED_ADD_EXTERNAL_FILES": "true",\n "Python.main.executor": "Run",\n "RunOnceActivity.ShowReadmeOnStart": "true",\n "git-widget-placeholder": "wire-py-reformat-14-08-2024",\n "last_opened_file_path": "/home/punix/Downloads/tkinter-bitcoin_price_converter_objectoriented(1).py"\n }\n} \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 1723279982210 \n \n \n 1723279982210 \n \n \n \n 1723666001005 \n \n \n \n 1723666001005 \n \n \n \n 1723666477079 \n \n \n \n 1723666477079 \n \n \n \n 1723847456806 \n \n \n \n 1723847456806 \n \n \n \n 1724013210356 \n \n \n \n 1724013210356 \n \n \n \n 1724013251954 \n \n \n \n 1724013251954 \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/workspace.xml b/.idea/workspace.xml
+--- a/.idea/workspace.xml
++++ b/.idea/workspace.xml
+@@ -4,10 +4,8 @@
+
+
+
+-
++
+
+-
+-
+
+
+
+@@ -129,10 +127,33 @@
+
+ 1724013251954
+
+-
++
++
++ 1724016284774
++
++
++
++ 1724016284774
++
++
+
+
+
++
++
++
++
++
++
++
++
++
++
++
++
++
++
++
+
+
+
+@@ -143,7 +164,7 @@
+
+
+
+-
++
+
+
+
+@@ -161,6 +182,7 @@
+
+
+
+-
++
++
+
+
+\ No newline at end of file
diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]1/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24,_06_49_[Changes]1/shelved.patch
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24__06_49__Changes_.xml b/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24__06_49__Changes_.xml
new file mode 100644
index 0000000..85897b2
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Checkout_at_19_08_24__06_49__Changes_.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/main.py b/main.py
index 0632394..05c1588 100644
--- a/main.py
+++ b/main.py
@@ -3,9 +3,7 @@ import os
import tkinter as tk
from tkinter import ttk
-from wg_func import tl_list, wg_export, wg_import_select, TunnelActiv
-
-wg_exp = wg_export()
+from wg_func import TunnelActiv, ListTunnels, ImportTunnel, ExportTunnels
class MainWindow(tk.Tk):
@@ -67,7 +65,7 @@ class FrameWidgets(ttk.Frame):
self.l_box.config(font=("Ubuntu", 12, "bold"))
self.l_box.grid(column=1, rowspan=3, row=1, )
- self.tl = tl_list()
+ self.tl = ListTunnels.tl_list()
for tunnels in self.tl:
self.l_box.insert("end", tunnels)
self.l_box.update()
@@ -80,7 +78,7 @@ class FrameWidgets(ttk.Frame):
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=15, sticky="s")
# Button Import
- self.btn_i = tk.Button(self, image=self.imp_pic, bd=0, command=wg_import_select)
+ 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)
def delete():
@@ -92,6 +90,8 @@ class FrameWidgets(ttk.Frame):
self.StrVar.set(value='')
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=15, sticky="s")
+ self.l_box.update()
+ self.l_box.select_set(0)
# Button Trash
self.btn_tr = tk.Button(self, image=self.tr_pic, bd=0, command=delete)
diff --git a/wg_func.py b/wg_func.py
index b8ed246..a1f5cf0 100644
--- a/wg_func.py
+++ b/wg_func.py
@@ -41,46 +41,72 @@ class TunnelActiv:
return active
-def tl_list():
- wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
- tl = wg_s[::3] # tl = Tunnel list # Show of 4.Element in list
- return tl
+class ListTunnels:
+ @staticmethod
+ def tl_list():
+ wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
+ tl = wg_s[::3] # tl = Tunnel list # Show of 4.Element in list
+ return tl
-def wg_import_select():
- try:
- filepath = filedialog.askopenfilename(initialdir=os.environ['HOME'], title="Select Wireguard config File",
- filetypes=[("WG config files", "*.conf")])
- file = open(filepath, 'r')
- read = file.read()
- file.close()
- pathsplit = filepath.split("/")
- pathsplit1 = pathsplit[-1]
- if "PrivateKey = " in read and "PublicKey = " in read:
- if len(pathsplit1) > 17:
- pathsplit = pathsplit1[len(pathsplit1) - 17:]
- os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
- os.system('nmcli connection down ' + str(TunnelActiv.active()))
- os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
- str(pathsplit))
- os.system('nmcli con mod ' + str(pathsplit[:-5]) + ' connection.autoconnect no')
- else:
- subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
- os.system('nmcli connection down ' + str(TunnelActiv.active()))
- os.system('nmcli connection import type wireguard file ' + str(filepath))
- os.system('nmcli con mod ' + str(pathsplit1[:-5]) + ' connection.autoconnect no')
- if "PrivateKey = " not in read:
- Message()
- except EOFError:
- pass
- except TypeError:
- pass
+class ImportTunnel:
+ def __init__(self):
+ self.wg_switch = None
+ self.btn_stst = None
+ self.lb_tunnel = None
+ self.StrVar = None
+ self.a = None
+ self.l_box = None
+
+ def wg_import_select(self):
+ try:
+ filepath = filedialog.askopenfilename(initialdir=os.environ['HOME'], title="Select Wireguard config File",
+ filetypes=[("WG config files", "*.conf")])
+ file = open(filepath, 'r')
+ read = file.read()
+ file.close()
+ pathsplit = filepath.split("/")
+ pathsplit1 = pathsplit[-1]
+ if "PrivateKey = " in read and "PublicKey = " in read:
+ if len(pathsplit1) > 17:
+ pathsplit = pathsplit1[len(pathsplit1) - 17:]
+ os.rename(filepath, os.environ['HOME'] + '/tester/' + str(pathsplit))
+ os.system('nmcli connection down ' + str(TunnelActiv.active()))
+ os.system('nmcli connection import type wireguard file ' + os.environ['HOME'] + '/tester/' +
+ str(pathsplit))
+ os.system('nmcli con mod ' + str(pathsplit[:-5]) + ' connection.autoconnect no')
+ else:
+ subprocess.call('cp ' + str(filepath) + ' ' + os.environ['HOME'] + '/tester/', shell=True)
+ os.system('nmcli connection down ' + str(TunnelActiv.active()))
+ os.system('nmcli connection import type wireguard file ' + str(filepath))
+ os.system('nmcli con mod ' + str(pathsplit1[:-5]) + ' connection.autoconnect no')
+ self.StrVar.set(value=' ')
+ self.a = TunnelActiv.active()
+ self.l_box.insert(0, self.a)
+ self.l_box.update()
+ self.StrVar = tk.StringVar()
+ self.StrVar.set(self.a)
+ self.lb_tunnel = tk.Label(self, textvariable=self.StrVar, fg='green')
+ self.lb_tunnel.config(font=("Ubuntu", 11, "bold"))
+ self.lb_tunnel.grid(column=3, row=1, sticky="w")
+ 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=15, sticky="s")
+ if "PrivateKey = " not in read:
+ Message()
+ except EOFError:
+ pass
+ except TypeError:
+ pass
+ except FileNotFoundError:
+ pass
-def wg_export():
- try:
- wg_exp = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
- wg_exp = wg_exp[1]
- return wg_exp
- except IndexError:
- pass
+class ExportTunnels:
+ @staticmethod
+ def wg_export():
+ try:
+ wg_exp = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
+ wg_exp = wg_exp[1]
+ return wg_exp
+ except IndexError:
+ pass