Skip to content

Instantly share code, notes, and snippets.

@sharl
Created December 18, 2013 03:02
Show Gist options
  • Save sharl/8016637 to your computer and use it in GitHub Desktop.
Save sharl/8016637 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import wx
TRAY_TOOLTIP = 'Master of Epic Monitor System'
TRAY_ICON = 'icon.png'
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.AppendItem(item)
return item
class TaskBarIcon(wx.TaskBarIcon):
def __init__(self):
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.IconFromBitmap(wx.Bitmap(path))
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
self.ShowBalloon("", "あなたのキャラが2chにさらされている可能性があります。", 5000)
def on_exit(self, event):
wx.CallAfter(self.Destroy)
if __name__ == '__main__':
app = wx.App()
TaskBarIcon()
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment