-
Notifications
You must be signed in to change notification settings - Fork 15
/
MsgBox.py
73 lines (58 loc) · 1.78 KB
/
MsgBox.py
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
#!/usr/bin/env python
#
# This file is part of Etherwall
# Copyright (C) Agus Bimantoro <[email protected]>
# This program is published under a GPLv3 license
import sys
import gtk
import gobject
# close windows automatically in */seconds
TIME_OUT = 10
class MsgBox():
def __init__(self, status, title, message):
""" Windows box to message end user if spoofing/poisoning attacks detected or if an error occurs in a daemon process """
self.status = int(status)
self.title = title
self.message = message
self.timeout = TIME_OUT
# set window box
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.set_icon_from_file("/opt/etherwall/etherwall.png")
self.window.set_size_request(540, 100)
self.window.set_resizable(False)
self.window.set_title(self.title)
# put label & image to window box
self.label = gtk.Label(self.message)
self.image = gtk.Image()
# 0 = error, 1 = warning
if (self.status==1):
self.image.set_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
else:
self.image.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)
self.h = gtk.HBox()
self.h.pack_start(self.image)
self.h.pack_start(self.label)
self.window.add(self.h)
# closed
self.window.connect('destroy', lambda q: gtk.main_quit())
# show all
self.window.show_all()
# start timer
self.counter = 0
# closing by time
# set periodic timer = 1
gobject.timeout_add_seconds(1, self.timer)
def timer(self):
self.counter += 1
if (self.counter == self.timeout):
gtk.main_quit()
elif (self.counter > self.timeout):
gtk.main_quit()
return True
def main(self):
gtk.main()
if (len(sys.argv) == 4):
msg=MsgBox(sys.argv[1], sys.argv[2], sys.argv[3])
msg.main()
## EOF ##