Compare commits
No commits in common. "f415fe7a6da0cdc7eb5d2d7c4e53ff98ab6c4b1e" and "3a8f5e1f53db39ac0e0e6c35188d0caae91ec4cd" have entirely different histories.
f415fe7a6d
...
3a8f5e1f53
@ -1,55 +0,0 @@
|
|||||||
import wx.adv
|
|
||||||
import wx
|
|
||||||
TRAY_TOOLTIP = 'Name'
|
|
||||||
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.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, 'Site', self.on_hello)
|
|
||||||
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_hello(self, event):
|
|
||||||
print ('Hello, world!')
|
|
||||||
|
|
||||||
def on_exit(self, event):
|
|
||||||
wx.CallAfter(self.Destroy)
|
|
||||||
self.frame.Close()
|
|
||||||
|
|
||||||
class App(wx.App):
|
|
||||||
def OnInit(self):
|
|
||||||
frame=wx.Frame(None)
|
|
||||||
self.SetTopWindow(frame)
|
|
||||||
TaskBarIcon(frame)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def main():
|
|
||||||
app = App(False)
|
|
||||||
app.MainLoop()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
Loading…
x
Reference in New Issue
Block a user