1 #!/usr/bin/python 2 3 from gi.repository import Gtk 4 5 filepattern = ( 6 ("MP3","*.mp3"), 7 ("AVI","*.avi"), 8 ("MPEG-4","*.mp4"), 9 ("FLV ","*.flv"), 10 ("OGG","*.ogg"), 11 ) 12 class main: 13 14 def __init__(self): 15 # Crea la ventana de trabajo Principal y obtiene los objetos en Glade 16 builder = Gtk.Builder() 17 builder.add_from_file("Multiplay.ui") 18 self.addfile = builder.get_object("Add") 19 self.addfolder = builder.get_object("AddFolder") 20 self.save = builder.get_object("Save") 21 self.about = builder.get_object("About") 22 self.filterbox = Gtk.FileFilter() 23 24 # Diccionario de eventos y Conexion de los mismos. 25 dict = {"on_Add_clicked": self.showAddFile, 26 "on_AddFolder_clicked": self.showAddFolder, 27 "on_Saved_clicked": self.showSave, 28 "on_About_clicked": self.showAbout, 29 } 30 builder.connect_signals(dict) 31 32 #Definicion del comando Agregar 33 def showAddFile(self, widget): 34 self.filterbox.set_name("Media Files") 35 for name, pattern in filepattern: 36 self.filterbox.add_pattern(pattern) 37 38 self.addfile.add_filter(self.filterbox) 39 40 respt = self.addfile.run() 41 self.addfile.remove_filter(self.filterbox) 42 self.addfile.hide() 43 if respt == -5: 44 fileselected = self.addfile.get_filenames() 45 print fileselected 46 47 48 #Definicion del comando Abrir Carpeta 49 def showAddFolder(self, widget): 50 self.filterbox.set_name("All Media Files") 51 for names, patterns in filepattern: 52 self.filterbox.add_pattern(patterns) 53 54 self.addfolder.add_filter(self.filterbox) 55 56 respt = self.addfolder.run() 57 self.addfolder.remove_filter(self.filterbox) 58 self.addfolder.hide() 59 60 if respt == -5: 61 addmultiple = self.addfolder.get_filename() 62 63 #Definicion del comando Guardar Permite guardar una lista 64 def showSave(self, widget): 65 self.save.run() 66 self.save.hide() 67 68 #Definicion del Comando Acerca de: 69 def showAbout(self, widget, data=None): 70 self.about.run() 71 self.about.hide() 72 73 74 #Ejecucion del programa 75 if __name__ == "__main__": 76 main() 77 Gtk.main()