add class Frame and class Massage, delete funktion go 100%, add resize window
This commit is contained in:
36
wg_func.py
36
wg_func.py
@ -3,7 +3,30 @@ import os
|
||||
import subprocess
|
||||
from tkinter import filedialog
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
|
||||
|
||||
class Message(tk.Tk):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.warning_pic = None
|
||||
self.x_width = 300
|
||||
self.y_height = 120
|
||||
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)
|
||||
self.title('Import error!')
|
||||
self.configure()
|
||||
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.label = tk.Label(self, image=self.warning_pic, text='Oh... no valid Wireguard File!\nPlease select a '
|
||||
'valid Wireguard File')
|
||||
self.label.config(font=("Ubuntu", 11), padx=15, pady=15)
|
||||
self.label.grid(column=0, row=0)
|
||||
self.button = tk.Button(self, text="OK", command=self.destroy)
|
||||
self.button.config(padx=15, pady=5)
|
||||
self.button.grid(column=0, row=1)
|
||||
|
||||
|
||||
def active(): # Shows the active tunnel
|
||||
@ -21,7 +44,7 @@ a = active()
|
||||
|
||||
def tl_list():
|
||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
tl = wg_s[::3] # tl = Tunnelliste # Hiermit wird jedes 4. Element der Liste gezeigt
|
||||
tl = wg_s[::3] # tl = Tunnel list # Show of 4.Element in list
|
||||
return tl
|
||||
|
||||
|
||||
@ -48,20 +71,13 @@ def wg_import_select():
|
||||
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:
|
||||
messagebox.showwarning(title="conf error", message=" Oh... no valid Wireguard File!\nPlease select a "
|
||||
"valid Wireguard File ")
|
||||
Message()
|
||||
except EOFError:
|
||||
pass
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
def tl_list():
|
||||
wg_s = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
tl = wg_s[::3] # tl = Tunnelliste # Hiermit wird jedes 4. Element der Liste gezeigt
|
||||
return tl
|
||||
|
||||
|
||||
def wg_export():
|
||||
try:
|
||||
wg_exp = os.popen('nmcli con show | grep -iPo "(.*)(wireguard)"').read().split()
|
||||
|
Reference in New Issue
Block a user