All pastes #428529 Raw Edit

Anonymous

public python v1 · immutable
·published 2007-04-07 17:03 UTC
rendered paste body
import wximport osclass 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, lambda event, hack=i:  self.domountimage(event, hack), temp2)            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 domountimage(self, i, hack=None):        dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.*", wx.OPEN)        if dlg.ShowModal() == wx.ID_OK:                self.image[hack]=dlg.GetPath()                print self.image                print ('cdemu '+str(hack)+' \''+self.image[hack]+'\'')                os.system('cdemu '+str(hack)+' \''+self.image[hack]+'\'')                os.system('gksu ''\'mount -t iso9660 /dev/cdemu/'+str(hack)+' /mnt/cdemu'+str(hack)+'\'')                self.updatetext(hack)        dlg.Destroy()                    def updatetext(self,hack):        print 'nothing here yet '+str(hack)            def showmenu(self, event):        self.PopupMenu(self.menu)        #start the appclass PenguinApp(wx.App):    def OnInit(self):        frame = PenguinTray(None, -1, ' ')        frame.Center(wx.BOTH)        frame.Show(False)        return Truedef main():    app = PenguinApp(0)    app.MainLoop()if __name__ == '__main__':    main()