-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI2.py
More file actions
114 lines (89 loc) · 4.51 KB
/
GUI2.py
File metadata and controls
114 lines (89 loc) · 4.51 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
class GUI:
def destroy(self, widget, data=None):
gtk.main_quit()
def setAddress(self, widget):
self.button5.hide() #hide address entry
self.textbox1.hide()
self.button6.show() #show port entry
self.textbox2.show()
def setPort(self, widget):
self.button6.hide() #hide port entry
self.textbox2.hide()
self.button4.show() #show send entry
self.textbox3.show()
def setClient(self, widget):
self.window.set_title("myVPN-Client")
self.button2.hide()
self.button5.show() #show address entry
self.textbox1.show()
def setServer(self, widget): #set as server side
self.window.set_title("myVPN-Server")
self.button1.hide()
self.button4.show() #show send entry
self.textbox3.show()
def sendmessage(self, widget):
self.label.set_text(self.textbox3.get_text())
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("destroy", self.destroy) #close shell on gui close
self.window.set_size_request(300,500) #windows size
self.window.set_title("myVPN") #window title
self.button1 = gtk.Button("Client") #button1 Client Selection
self.button1.connect("clicked", self.setClient) #what fn to call when clicked
self.button2 = gtk.Button("Server") #button2 Server Selection
self.button2.connect("clicked", self.setServer)
self.button3 = gtk.Button("Terminate") #button3 terminate
self.button3.connect("clicked", self.destroy)
self.button4 = gtk.Button("Send") #button4 send
self.button4.connect("clicked", self.sendmessage)
self.button5 = gtk.Button("Set Address") #button5 Set Address
self.button5.connect("clicked", self.setAddress)
self.button6 = gtk.Button("Set Port") #button6 Set Port
self.button6.connect("clicked", self.setPort)
self.textbox1 = gtk.Entry() #Address
#self.textbox1.connect("changed", self.sendmessage)
self.textbox2 = gtk.Entry() #Port
#self.textbox1.connect("changed", self.sendmessage)
self.textbox3 = gtk.Entry() #Msg to send
#self.textbox1.connect("changed", self.sendmessage)
self.hbox1=gtk.HBox() #Level 1, Client/Server Selection
self.hbox1.pack_start(self.button1)
self.hbox1.pack_start(self.button2)
self.hbox2=gtk.HBox() #Level 2, blank on initialization
self.hbox2.pack_start(self.textbox1) #address
self.hbox2.pack_start(self.button5)
self.hbox2.pack_start(self.textbox2) #port
self.hbox2.pack_start(self.button6)
self.hbox2.pack_start(self.textbox3) #msg
self.hbox2.pack_start(self.button4)
self.hbox3 = gtk.HBox() #Level 3, display msg
self.frame = gtk.Frame("Chat Box")
self.label = gtk.Label("Hello")
#label.set_justify(gtk.JUSTIFY_FILL)
self.frame.add(self.label)
self.hbox3.pack_start(self.frame, True, True, 0)
self.hbox4=gtk.HBox() #Level 4, Termination
self.hbox4.pack_start(self.button3)
self.vbox1=gtk.VBox() #Put all hbox into vbox
self.vbox1.pack_start(self.hbox1)
self.vbox1.pack_start(self.hbox2)
self.vbox1.pack_start(self.hbox3)
self.vbox1.pack_start(self.hbox4)
self.window.add(self.vbox1) #add vBox1 to window
self.window.show_all() #display window
self.button5.hide() #hide all level2 box first
self.textbox1.hide()
self.button6.hide()
self.textbox2.hide()
self.button4.hide()
self.textbox3.hide()
def main(self):
gtk.main()
#-----------------------------Code Begin-----------------------------
if __name__ == "__main__":
gui = GUI()
gui.main()