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