|
|
|
import glob
|
|
|
|
import wx
|
|
|
|
import wx.adv
|
|
|
|
import os
|
|
|
|
from time import sleep
|
|
|
|
from sys import platform
|
|
|
|
import sys
|
|
|
|
from util import find_data_file
|
|
|
|
from util import fprint
|
|
|
|
from util import setup_child
|
|
|
|
|
|
|
|
TRAY_TOOLTIP = 'IP Pigeon'
|
|
|
|
|
|
|
|
displaydata = None
|
|
|
|
settings = None
|
|
|
|
|
|
|
|
killme = False
|
|
|
|
|
|
|
|
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)
|
|
|
|
create_menu_item(menu, 'Login test', self.on_login)
|
|
|
|
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):
|
|
|
|
fprint ('Tray icon was left-clicked.')
|
|
|
|
|
|
|
|
def on_open(self, event):
|
|
|
|
settings["showui"] = True
|
|
|
|
self.close_popup()
|
|
|
|
|
|
|
|
def on_login(self, event):
|
|
|
|
settings["username"] = "frontend"
|
|
|
|
settings["password"] = "qwertyuiop"
|
|
|
|
settings["login"] = True
|
|
|
|
|
|
|
|
def on_exit(self, event):
|
|
|
|
wx.CallAfter(self.Destroy)
|
|
|
|
global killme
|
|
|
|
killme.value += 1
|
|
|
|
self.close_popup()
|
|
|
|
#print("kill cmd")
|
|
|
|
|
|
|
|
|
|
|
|
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):
|
|
|
|
setup_child()
|
|
|
|
global killme
|
|
|
|
global settings
|
|
|
|
global displaydata
|
|
|
|
killme = kill
|
|
|
|
app = TaskbarApp(False)
|
|
|
|
displaydata = data
|
|
|
|
settings = sets
|
|
|
|
fprint("Creating taskbar icon")
|
|
|
|
app.MainLoop()
|
|
|
|
|
|
|
|
TRAY_ICON = find_data_file('icon.png')
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
background(list(), dict(), int())
|