これは私のスクリプトです。何らかの理由で、もう機能しません。それは以前に行っています。誰かが潜在的なエラーを追跡できますか?
#! /usr/bin/env python
import wx
import os
TRAY_TOOLTIP = 'jmtpfs mounter'
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.off=wx.IconFromBitmap(wx.Bitmap("android_off.png"))
self.SetIcon(self.off)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Mount', self.mount)
create_menu_item(menu, 'UnMount', self.unmount)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def on_left_down(self, event):
print 'Tray icon was left-clicked.'
def mount(self, event):
retvalue = os.system("jmtpfs ~/Nexus")
print retvalue
self.on=wx.IconFromBitmap(wx.Bitmap("android_on.png"))
self.SetIcon(self.on)
def unmount(self, event):
retvalue = os.system("fusermount -u ~/Nexus")
print retvalue
self.off=wx.IconFromBitmap(wx.Bitmap("android_off.png"))
self.SetIcon(self.off)
def on_exit(self, event):
wx.CallAfter(self.Destroy)
def main():
app = wx.PySimpleApp()
TaskBarIcon()
app.MainLoop()
if __name__ == '__main__':
main()
トレースを実行すると、次のようになります。
mounter.py(17): self.SetIcon(self.off) --- モジュール名: _windows、funcname: SetIcon _windows.py(2174):ウィンドウを返す .TaskBarIcon_SetIcon(*args, **kwargs) mounter.py(18) : self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down) --- modulename: _core, funcname: Bind _core.py(3916): assert isinstance(event, wx.PyEventBinder) _core.py(3917): assert handler is None or callable(handler) _core.py(3918): assert source is None or hasattr(source, 'GetId') _core.py(3919): if source is not None: _core.py(3921): event.Bind(self 、id、id2、ハンドラ)
--- modulename: _core, funcname: Bind _core.py(3994): for et in self.evtType: _core.py(3995): target.Connect(id1, id2, et, function) --- modulename: _core, funcname: Connect _core.py(3875): return core .EvtHandler_Connect(*args, **kwargs) _core.py(3994): for et in self.evtType: mounter.py(44): app.MainLoop() -- - modulename: _core, funcname: MainLoop _core.py(8010): wx.PyApp.MainLoop(self) --- modulename: _core, funcname: MainLoop _core.py(7306): return core .PyApp_MainLoop(*args, **クワーグス)