forked from spacemudd/webagent-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysTrayIcon.py
38 lines (32 loc) · 973 Bytes
/
sysTrayIcon.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
import wx.adv
import sys
import wx
import tornado
TRAY_TOOLTIP = 'Scanner Web-Agent'
TRAY_ICON = '24x24.png'
class App(wx.App):
def OnInit(self):
frame = wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
class TaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
icon = wx.Icon(wx.Bitmap(TRAY_ICON))
self.SetIcon(icon, TRAY_TOOLTIP)
self.Bind(wx.adv.EVT_TASKBAR_RIGHT_DOWN, self.CreatePopupMenu)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.frame.Close()
sys.exit()
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.Append(item)
return item