This repository was archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView.py
More file actions
363 lines (309 loc) · 14.7 KB
/
View.py
File metadata and controls
363 lines (309 loc) · 14.7 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
# generated by wxGlade 0.4.1 on Fri Mar 6 08:51:48 2009
import wx, sys
from Constants import *
class messageDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: messageDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.sizer_17_staticbox = wx.StaticBox(self, -1, "Select Destination")
self.sizer_16_staticbox = wx.StaticBox(self, -1, "Message Contents")
self.messageBoxText = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
self.messageDestCombo = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
self.messageDestCombo.SetMinSize((200, 27))
self.finalSendMessageButton = wx.Button(self, 1, "Send Message")
self.__set_properties()
self.__do_layout()
# end wxGlade
self.Bind(wx.EVT_BUTTON, self.OnYes, id=1)
def OnYes(self, event):
self.Close()
# end wxGlade
def __set_properties(self):
# begin wxGlade: messageDialog.__set_properties
self.SetTitle("Send Message")
self.SetSize((432, 353))
self.messageDestCombo.SetSize((200, 27))
# end wxGlade
def __do_layout(self):
# begin wxGlade: messageDialog.__do_layout
sizer_15 = wx.BoxSizer(wx.VERTICAL)
sizer_18 = wx.BoxSizer(wx.HORIZONTAL)
sizer_19 = wx.BoxSizer(wx.HORIZONTAL)
sizer_17 = wx.StaticBoxSizer(self.sizer_17_staticbox, wx.HORIZONTAL)
sizer_16 = wx.StaticBoxSizer(self.sizer_16_staticbox, wx.HORIZONTAL)
sizer_16.Add(self.messageBoxText, 2, wx.EXPAND|wx.ADJUST_MINSIZE|wx.FIXED_MINSIZE, 0)
sizer_15.Add(sizer_16, 1, wx.EXPAND, 0)
sizer_17.Add(self.messageDestCombo, 0, wx.EXPAND, 0)
sizer_15.Add(sizer_17, 0, wx.EXPAND, 0)
sizer_19.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0)
sizer_19.Add(self.finalSendMessageButton, 0, wx.ADJUST_MINSIZE, 0)
sizer_18.Add(sizer_19, 1, wx.EXPAND, 0)
sizer_15.Add(sizer_18, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_15)
self.Layout()
# end wxGlade
# end of class messageDialog
class blackListDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: blackListDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
if useBlackList: self.blackListLabel = wx.StaticText(self, -1, "Blacklist")
else: self.blackListLabel = wx.StaticText(self, -1, "Whitelist")
self.text_ctrl = wx.TextCtrl(self, 2, style=wx.TE_MULTILINE)
self.okButton = wx.Button(self, 1, "OK")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.OnYes, id=1)
def OnYes(self, event):
self.Close()
# end wxGlade
def __set_properties(self):
# begin wxGlade: blackListDialog.__set_properties
if useBlackList: self.SetTitle("Edit Blacklist...")
else: self.SetTitle("Edit Whitelist...")
self.SetSize((426, 341))
self.okButton.SetDefault()
# end wxGlade
def __do_layout(self):
# begin wxGlade: blackListDialog.__do_layout
sizer_4 = wx.BoxSizer(wx.VERTICAL)
sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
sizer_7 = wx.BoxSizer(wx.VERTICAL)
sizer_7.Add(self.blackListLabel, 0, wx.ADJUST_MINSIZE, 0)
sizer_7.Add(self.text_ctrl, 1, wx.EXPAND, 0)
sizer_4.Add(sizer_7, 1, wx.EXPAND, 0)
sizer_8.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0)
sizer_8.Add(self.okButton, 0, wx.ADJUST_MINSIZE, 0)
sizer_4.Add(sizer_8, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_4)
self.Layout()
# end wxGlade
# end of class blackListDialog
class ogmPreferences(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: ogmPreferences.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.timeLabel = wx.StaticText(self, -1, "Time Between OGMs")
self.ogmTimerCtrl = wx.TextCtrl(self, -1, "1")
self.label_2 = wx.StaticText(self, -1, "TTL")
self.ttlCtrl = wx.SpinCtrl(self, -1, "5", min=0, max=100)
self.okButton = wx.Button(self, -1, "OK")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: ogmPreferences.__set_properties
self.SetTitle("dialog_2")
self.SetSize((215, 151))
# end wxGlade
def __do_layout(self):
# begin wxGlade: ogmPreferences.__do_layout
sizer_9 = wx.BoxSizer(wx.VERTICAL)
sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
sizer_21 = wx.BoxSizer(wx.VERTICAL)
sizer_20 = wx.BoxSizer(wx.VERTICAL)
sizer_20.Add(self.timeLabel, 0, wx.ADJUST_MINSIZE, 0)
sizer_20.Add(self.ogmTimerCtrl, 0, wx.ADJUST_MINSIZE, 0)
sizer_9.Add(sizer_20, 1, wx.EXPAND, 0)
sizer_21.Add(self.label_2, 0, wx.ADJUST_MINSIZE, 0)
sizer_21.Add(self.ttlCtrl, 0, wx.ADJUST_MINSIZE, 0)
sizer_9.Add(sizer_21, 1, wx.EXPAND, 0)
sizer_10.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0)
sizer_10.Add(self.okButton, 0, wx.ADJUST_MINSIZE, 0)
sizer_9.Add(sizer_10, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_9)
self.Layout()
# end wxGlade
# end of class ogmPreferences
class checkInterfaceDialog(wx.Dialog):
def __init__(self, *args, **kwds):
# begin wxGlade: checkInterfaceDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.THICK_FRAME
wx.Dialog.__init__(self, *args, **kwds)
self.text_ctrl_1 = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.okButton = wx.Button(self, -1, "OK")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: checkInterfaceDialog.__set_properties
self.SetTitle("Check Interface")
self.SetSize((428, 285))
# end wxGlade
def __do_layout(self):
# begin wxGlade: checkInterfaceDialog.__do_layout
sizer_23 = wx.BoxSizer(wx.VERTICAL)
sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
sizer_23.Add(self.text_ctrl_1, 1, wx.ALL|wx.EXPAND|wx.ADJUST_MINSIZE, 3)
sizer_24.Add((20, 20), 1, wx.ADJUST_MINSIZE, 0)
sizer_24.Add(self.okButton, 0, wx.ADJUST_MINSIZE, 0)
sizer_23.Add(sizer_24, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_23)
self.Layout()
# end wxGlade
# end of class checkInterfaceDialog
class YOBATFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: YOBATFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.sizer_22_staticbox = wx.StaticBox(self, -1, "Routing Table")
self.sizer_25_staticbox = wx.StaticBox(self, -1, "Recieved Messages")
self.sizer_5_staticbox = wx.StaticBox(self, -1, "Packet List")
# Menu Bar
self.mainFrame_menubar = wx.MenuBar()
self.SetMenuBar(self.mainFrame_menubar)
wxglade_tmp_menu = wx.Menu()
wxglade_tmp_menu.Append(1, "Node On", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.Append(2, "Node Off", "", wx.ITEM_NORMAL)
self.mainFrame_menubar.Append(wxglade_tmp_menu, "Node Control")
wxglade_tmp_menu = wx.Menu()
if useBlackList : wxglade_tmp_menu.Append(3, "Edit Blacklist", "", wx.ITEM_NORMAL)
else: wxglade_tmp_menu.Append(3, "Edit Whitelist", "", wx.ITEM_NORMAL)
self.mainFrame_menubar.Append(wxglade_tmp_menu, "Node Prefs")
wxglade_tmp_menu = wx.Menu()
#wxglade_tmp_menu.Append(8, "Create Diagram Of Network", "", wx.ITEM_NORMAL)
wxglade_tmp_menu.Append(9, "Exit", "", wx.ITEM_NORMAL)
self.mainFrame_menubar.Append(wxglade_tmp_menu, "Etc")
# Menu Bar end
self.packetList = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.routingTable = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
self.messageList = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
#Set up the list ctrls
self.packetList.InsertColumn(0, 'In/Out',width=50)
self.packetList.InsertColumn(1, 'Type')
self.packetList.InsertColumn(2, 'Sender',width=150)
self.packetList.InsertColumn(3, 'Reciever',width=150)
self.packetList.InsertColumn(4, 'Message', width=200)
self.routingTable.InsertColumn(0, 'Destination', width=150)
self.routingTable.InsertColumn(1, 'Next Best Hop', width=150)
self.routingTable.InsertColumn(2, 'Local Link', width=90)
self.routingTable.InsertColumn(3, 'TTL Value', width=90)
self.routingTable.InsertColumn(4, 'Sequence #', width=90)
self.routingTable.InsertColumn(5, 'Time Until Deletion', width= 90)
self.messageList.InsertColumn(0, 'From', width=150)
self.messageList.InsertColumn(1, 'Message', width=300)
self.interfaceStatus = wx.StaticText(self, -1, "")
self.static_line_1 = wx.StaticLine(self, -1, style=wx.LI_VERTICAL)
self.nodeStatus = wx.StaticText(self, -1, "Node Off")
self.sendMessageButton = wx.Button(self, 10, "Send Message")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: YOBATFrame.__set_properties
self.SetTitle("YOBATMAN Routing Tool")
self.SetSize((950, 500))
self.interfaceStatus.SetForegroundColour(wx.Colour(255, 15, 0))
self.interfaceStatus.SetFont(wx.Font(13, wx.DECORATIVE, wx.NORMAL, wx.NORMAL, 0, ""))
self.nodeStatus.SetForegroundColour(wx.Colour(255, 15, 0))
self.nodeStatus.SetFont(wx.Font(13, wx.DECORATIVE, wx.NORMAL, wx.NORMAL, 0, ""))
# end wxGlade
def __do_layout(self):
# begin wxGlade: YOBATFrame.__do_layout
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
sizer_12 = wx.BoxSizer(wx.VERTICAL)
sizer_13 = wx.BoxSizer(wx.HORIZONTAL)
sizer_14 = wx.BoxSizer(wx.HORIZONTAL)
sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
sizer_3 = wx.BoxSizer(wx.HORIZONTAL)
sizer_6 = wx.BoxSizer(wx.VERTICAL)
sizer_25 = wx.StaticBoxSizer(self.sizer_25_staticbox, wx.HORIZONTAL)
sizer_22 = wx.StaticBoxSizer(self.sizer_22_staticbox, wx.HORIZONTAL)
sizer_5 = wx.StaticBoxSizer(self.sizer_5_staticbox, wx.VERTICAL)
sizer_5.Add(self.packetList, 1, wx.EXPAND, 0)
sizer_3.Add(sizer_5, 1, wx.EXPAND, 0)
sizer_22.Add(self.routingTable, 1, wx.EXPAND, 0)
sizer_6.Add(sizer_22, 1, wx.EXPAND, 0)
sizer_25.Add(self.messageList, 1, wx.EXPAND, 0)
sizer_6.Add(sizer_25, 1, wx.EXPAND, 0)
sizer_3.Add(sizer_6, 1, wx.EXPAND, 0)
sizer_2.Add(sizer_3, 1, wx.EXPAND, 0)
sizer_13.Add(self.interfaceStatus, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 8)
sizer_1.Add(self.static_line_1, 0, wx.EXPAND, 0)
sizer_1.Add(self.nodeStatus, 0, wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 8)
sizer_14.Add(sizer_1, 1, wx.EXPAND, 0)
sizer_14.Add(self.sendMessageButton, 0, 0, 0)
sizer_13.Add(sizer_14, 1, wx.EXPAND, 0)
sizer_12.Add(sizer_13, 1, wx.EXPAND, 0)
sizer_11.Add(sizer_12, 1, wx.EXPAND, 0)
sizer_2.Add(sizer_11, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_2)
self.Layout()
# end wxGlade
def UpdateList(self, ListIndex, Info):
if ListIndex == 0:
index = self.packetList.InsertStringItem(sys.maxint, Info[0])
self.packetList.SetStringItem(index, 1, Info[1])
self.packetList.SetStringItem(index, 2, Info[2])
self.packetList.SetStringItem(index, 3, Info[3])
self.packetList.SetStringItem(index, 4, Info[4])
self.packetList.Focus(index)
elif ListIndex == 1:
self.routingTable.DeleteAllItems()
for destination,destInfo in Info.iteritems():
index = self.routingTable.InsertStringItem(sys.maxint, destination)
self.routingTable.SetStringItem(index, 1, destInfo[0])
if destInfo[0].strip() == destination.strip(): self.routingTable.SetStringItem(index, 2, "YES")
else: self.routingTable.SetStringItem(index, 2, "NO")
self.routingTable.SetStringItem(index, 3, destInfo[1])
self.routingTable.SetStringItem(index, 4, destInfo[2])
self.routingTable.SetStringItem(index, 5, str(destInfo[3]))
self.routingTable.Focus(index)
elif ListIndex == 3:
index = self.messageList.InsertStringItem(sys.maxint, Info[0])
self.messageList.SetStringItem(index, 1, Info[1])
def NodeStatusUpdate(self, UP):
if not UP:
self.nodeStatus.SetLabel("Node Off")
self.nodeStatus.SetForegroundColour(wx.Colour(255, 15, 0))
else:
self.nodeStatus.SetLabel("Node On")
self.nodeStatus.SetForegroundColour(wx.Colour(000, 204, 017))
def StartUpBlackListEditor(self, BlackList, BlackListQueue):
editDialog = blackListDialog(self)
editDialog.text_ctrl.Clear()
for item in BlackList:
if not item.isspace() and item != '':
editDialog.text_ctrl.WriteText(item + "\n")
editDialog.ShowModal()
newBlackList = editDialog.text_ctrl.GetValue().split("\n")
for item in newBlackList:
item = item.strip()
editDialog.Destroy()
BlackListQueue.put(newBlackList)
def StartUpMessageEditor(self, ConnectedNodes, NewMessageQueue):
newMessageDialog = messageDialog(self)
listOfAvailNodes = ConnectedNodes
newMessageDialog.messageDestCombo.AppendItems(listOfAvailNodes)
newMessageDialog.ShowModal()
newMessage = newMessageDialog.messageBoxText.GetValue()
newMessage = newMessage.replace("/", "\\")
recieverChoice = newMessageDialog.messageDestCombo.GetValue()
NewMessageQueue.put((recieverChoice, newMessage))
newMessageDialog.Destroy()
def UpdateTitle(self, Address):
self.SetTitle("YOBATMAN Routing Tool" + " Address: " + str(Address))
# end of class YOBATFrame
class YOBATMANGUI(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
self.mainFrame = YOBATFrame(None, -1, "")
self.SetTopWindow(self.mainFrame)
self.mainFrame.Show()
return 1
# end of class YOBATMANGUI
if __name__ == "__main__":
YOBATMAN = YOBATMANGUI(0)
YOBATMAN.MainLoop()