-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenvpn
70 lines (64 loc) · 2.01 KB
/
openvpn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python3
import os
import tkinter as tk
import tkinterdnd2
from tkinter.constants import ACTIVE, LEFT, RIGHT
from tkinterdnd2 import *
from tkinter import END, Button, Label, Listbox, filedialog
from tkinter import messagebox
# OpenVPN GUI Version for Linux
# Code by Mugi F.
# My Github http://github.com/mugi789
# tkinter
root = tk.Tk()
root.title("OpenVPN GUI Version")
root.geometry('450x300')
# script open file
def click():
filename = filedialog.askopenfilename(
title='Open File Config',
initialdir=os.getcwd(),
filetypes=(
('Config VPN', '*.ovpn'),
('All Files', '*.*')
))
if filename:
os.popen("xterm -e 'sudo openvpn --config "+filename+"'").read()
else:
root
# script dnd
def drags():
top = tkinterdnd2.Tk()
top.title("OpenVPN GUI Version")
top.geometry("450x300")
Label(top).pack(pady=3)
Label(top, text="Drag and Drop VPN Config to Here").pack()
Label(top).pack()
def input(event):
lb.insert("end", event.data)
lb = Listbox(top, width=37, height=5)
lb.pack()
lb.drop_target_register(DND_FILES)
lb.dnd_bind('<<Drop>>', input)
def cmd():
os.popen("xterm -e 'sudo openvpn --config "+lb.get(ACTIVE)+"'").read()
def clear():
lb.delete(0, END)
Button(top, text=" Clear ", command=clear).pack(pady=8)
Button(top, text=" Select ", command=cmd).pack(side=RIGHT, padx=50)
Button(top, text=" Back ", command=top.destroy).pack(side=LEFT, padx=50)
# tombol keluar
def keluar():
iya = messagebox.askquestion("Warning",
"Do You Want to Exit? ?",
icon='question')
if iya == 'yes':
root.destroy()
else:
root
# menu awal
Label(root, text="OpenVPN GUI Version for Linux\r\nCreated by Mugi Fadilah\nhttp://github.com/mugi789").pack(pady=20)
Button(root, text=" -= Open Config =- ", command=click).pack()
Button(root, text="-= Drag and Drop =-", command=drags).pack()
Button(root, text="-== Exit ==-", command=keluar).pack(expand=True)
tk.mainloop()