import wx import os class PenguinTray(wx.Frame): #Create Objects def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title, size = (1, 1), style=wx.FRAME_NO_TASKBAR|wx.NO_FULL_REPAINT_ON_RESIZE) self.image=['No media']*10 self.tbicon = wx.TaskBarIcon() self.Show(True) self.menu=wx.Menu() self.virtual=wx.Menu() self.optionsmenu=wx.Menu() self.layoutstuff() #Layout the previously created objects def layoutstuff(self): icon = wx.Icon('/usr/share/pixmaps/fall-back-wm-select.png', wx.BITMAP_TYPE_PNG) self.tbicon.SetIcon(icon, 'Penguin Tools') #self.mountimage0item=wx.MenuItem(self.virtual0, -1, 'Mount Image') #self.virtual0.AppendItem(self.mountimage0item) #self.virtual0.Append(-1,'Unmount Image') adict = { } for i in range(10): #self.virtual+str(i)=wx.Menu() temp = adict['virtual%d' % i] = wx.Menu() temp2 = adict['mountimage%d' %i] = wx.MenuItem(adict['virtual%d' %i], -1, 'Mount Image') temp.AppendItem(temp2) temp.Append(-1, 'Unmount Image') self.Bind(wx.EVT_MENU, adict['self.domountimage%d' %i], adict['mountimage%d' %i]) self.virtual.AppendMenu(-1, 'Device '+str(i)+':[/mnt/cdemu'+str(i)+'] '+self.image[i],temp) self.virtual.AppendSeparator() self.virtual.Append(-1, 'Unmount all drives') self.menu.AppendMenu(-1, "Virtual CD/DVD-ROM",self.virtual) self.menu.AppendMenu(-1, "Options", self.optionsmenu) self.menu.AppendSeparator() self.menu.Append(wx.ID_EXIT, "Exit") self.Bind(wx.EVT_MENU, self.quit, id=wx.ID_EXIT) #self.Bind(wx.EVT_MENU, self.mountimage0, self.mountimage0item) wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.quit) wx.EVT_TASKBAR_RIGHT_UP(self.tbicon, self.showmenu) def quit (self, event): self.Close(True) def domountimage0(self,event): dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.*", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.image[0]=dlg.GetPath() print self.image[0] dlg.Destroy() def showmenu(self, event): self.PopupMenu(self.menu) #start the app class PenguinApp(wx.App): def OnInit(self): frame = PenguinTray(None, -1, ' ') frame.Center(wx.BOTH) frame.Show(False) return True def main(): app = PenguinApp(0) app.MainLoop() if __name__ == '__main__': main()