diff options
author | Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org> | 2013-04-21 14:43:33 (GMT) |
---|---|---|
committer | Ignacio Rodríguez <ignaciorodriguez@sugarlabs.org> | 2013-04-21 14:43:33 (GMT) |
commit | 02cd269f423a3a30fc35fd0680201cd876b67023 (patch) | |
tree | 2d15b478b9d6ebd59d025a36614ed9ba0358b93a /Widgets.py | |
parent | 868b9dc1684c3928d71567ac0bd8b5eb04e18f39 (diff) |
Clase para autores, devuelve datos.
Diffstat (limited to 'Widgets.py')
-rw-r--r-- | Widgets.py | 92 |
1 files changed, 88 insertions, 4 deletions
@@ -354,6 +354,19 @@ class DialogoProyecto(Gtk.Dialog): self.icon_path = Gtk.Label() self.combo_tipo = Gtk.ComboBoxText() + ### Box para despues agregarlo a un scroll + self.box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) + + ### Scroll + scroll = Gtk.ScrolledWindow() + scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + scroll.add_with_viewport(self.box) + + self.vbox.pack_start(scroll, True, True, 0) + + ### Autores + self.autores = Autores() + ### Imagen para el preview del icono self._icono_preview = Gtk.Image() @@ -392,10 +405,13 @@ class DialogoProyecto(Gtk.Dialog): self._icono_preview, boton_buscar_icono] ), self.__get_pack_box( [self.__get_label('Tipo del Proyecto:'), - self.combo_tipo] )] + self.combo_tipo] ), + self.__get_pack_box( + [self.__get_label("Autores:"), + self.autores] ) ] for widget in internal_widgets: - self.vbox.pack_start(widget, True, True, 3) + self.box.pack_start(widget, True, True, 3) for licencia in ['GPL2', 'GPL3', 'LGPL 2.1', 'LGPL 3', 'BSD', 'MIT X11']: self.licencia.append_text(licencia) @@ -499,7 +515,8 @@ class DialogoProyecto(Gtk.Dialog): "licencia": self.licencia.get_active_text(), "tipo": self.combo_tipo.get_active_text(), "icon_path": self.icon_path.get_text(), - "url": self.url.get_text() + "url": self.url.get_text(), + "autores": self.autores.get_datos() } return dict @@ -567,4 +584,71 @@ class My_FileChooser(Gtk.FileChooserDialog): def __salir(self, widget): self.destroy() -
\ No newline at end of file + +class Autores(Gtk.Box): + """ + Box para agregar datos de los Autores + """ + + def __init__(self): + Gtk.Box.__init__(self, + orientation = Gtk.Orientation.HORIZONTAL) + + self.nombres = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) + self.emails = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) + self.botones = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) + + self.agregar = get_boton(Gtk.STOCK_ADD, "Agregar") + self.agregar.connect("clicked", self.__agregar) + + + self.pack_start(self.nombres, True, True, 0) + self.pack_start(self.botones, False, False, 0) + self.pack_start(self.emails, True, True, 0) + self.pack_end(self.agregar, False, False, 0) + + self.show_all() + + def __agregar(self, widget): + """ + Función para agregar dos entrys, en ellos van el nombre y email + """ + + entry1 = Gtk.Entry() + entry2 = Gtk.Entry() + self.nombres.pack_start(entry1, True, True, 0) + + remover = get_boton(Gtk.STOCK_REMOVE, "Eliminar") + remover.connect("clicked", self.__quitar, entry1, entry2) + + self.botones.pack_start(remover, False, False, 0) + self.emails.pack_start(entry2, True, True, 0) + self.show_all() + + def __quitar(self, widget, nombre, email): + """ + Función para eliminar los widgets de un autor + """ + + self.nombres.remove(nombre) + self.emails.remove(email) + self.botones.remove(widget) + self.show_all() + self.mostrar() + + def get_datos(self): + """ + Devuelve una lista con los datos de los autores + """ + + datos = [] + actual = 0 + Widgets_Nombre = self.nombres.get_children() + Widgets_Email = self.emails.get_children() + + for nombre in Widgets_Nombre: + email = Widgets_Email[actual] + datos.append((nombre.get_text(), email.get_text())) + actual += 1 + + return datos |