You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
Python
79 lines
1.9 KiB
Python
import glob
|
|
import wx
|
|
import wx.adv
|
|
import os
|
|
from time import sleep
|
|
from sys import platform
|
|
import sys
|
|
|
|
TRAY_TOOLTIP = 'IP Pigeon'
|
|
|
|
displaydata = None
|
|
settings = None
|
|
|
|
killme = False
|
|
|
|
def find_data_file(filename):
|
|
if getattr(sys, "frozen", False):
|
|
# The application is frozen
|
|
datadir = os.path.dirname(sys.executable)
|
|
else:
|
|
# The application is not frozen
|
|
# Change this bit to match where you store your data files:
|
|
datadir = os.path.dirname(__file__)
|
|
return os.path.join(datadir, filename)
|
|
|
|
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
|
|
|
|
class TaskBarIcon(wx.adv.TaskBarIcon):
|
|
def __init__(self, frame):
|
|
self.frame = frame
|
|
super(TaskBarIcon, self).__init__()
|
|
self.set_icon(TRAY_ICON)
|
|
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
|
|
|
|
def CreatePopupMenu(self):
|
|
menu = wx.Menu()
|
|
create_menu_item(menu, 'Control Panel', self.on_open)
|
|
menu.AppendSeparator()
|
|
create_menu_item(menu, 'Exit', self.on_exit)
|
|
return menu
|
|
|
|
def set_icon(self, path):
|
|
icon = wx.Icon(path)
|
|
self.SetIcon(icon, TRAY_TOOLTIP)
|
|
|
|
def on_left_down(self, event):
|
|
print ('Tray icon was left-clicked.')
|
|
|
|
def on_open(self, event):
|
|
foreground()
|
|
#self.close_popup()
|
|
|
|
def on_exit(self, event):
|
|
wx.CallAfter(self.Destroy)
|
|
self.close_popup()
|
|
killme[0] = True
|
|
|
|
def close_popup(self):
|
|
self.frame.Close()
|
|
|
|
class TaskbarApp(wx.App):
|
|
def OnInit(self):
|
|
frame=wx.Frame(None)
|
|
self.SetTopWindow(frame)
|
|
TaskBarIcon(frame)
|
|
return True
|
|
|
|
def background(data, sets, kill):
|
|
killme = kill
|
|
app = TaskbarApp(False)
|
|
displaydata = data
|
|
settings = sets
|
|
app.MainLoop()
|
|
|
|
TRAY_ICON = find_data_file('icon.png') |