diff options
author | flavio <fdanesse@gmail.com> | 2013-03-29 21:16:46 (GMT) |
---|---|---|
committer | flavio <fdanesse@gmail.com> | 2013-03-29 21:32:26 (GMT) |
commit | 344e320ad6d6b2e4e84f0089546fb0b6befe51ca (patch) | |
tree | bc10d191943053409586c77bfe8e132b0ce027e3 | |
parent | 54d182c4c100dcd5ba62cc0b6a70d0e2e7d91c18 (diff) |
Corrections
-rw-r--r-- | CeibalEncuesta/Widgets.py | 686 |
1 files changed, 346 insertions, 340 deletions
diff --git a/CeibalEncuesta/Widgets.py b/CeibalEncuesta/Widgets.py index 7a857f4..29099b5 100644 --- a/CeibalEncuesta/Widgets.py +++ b/CeibalEncuesta/Widgets.py @@ -32,7 +32,7 @@ HOME = os.environ["HOME"] WORKPATH = os.path.join(HOME, "CeibalEncuesta") class Panel(Gtk.Paned): - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, @@ -44,252 +44,252 @@ class Panel(Gtk.Paned): GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING))} - + def __init__(self): - + Gtk.Paned.__init__(self, orientation = Gtk.Orientation.HORIZONTAL) - + self.encuestados = None # mantiene csv para guardarlo como tal self.lista = None # Lista() Lista de encuestados self.encuesta = None # Dict Encuesta self.dependencies = None # Dependencias preguntas - respuestas - + # Izquierda box = Gtk.VBox() - + self.scroll_list = Gtk.ScrolledWindow() - + self.scroll_list.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) # self.scroll_list.add_with_viewport(self.lista) - + box.pack_start(self.scroll_list, True, True, 0) - + self.pack1(box, resize = False, shrink = True) - + # Derecha base_box = Gtk.VBox() - + self.box_encuesta = Gtk.VBox() scroll = Gtk.ScrolledWindow() - + scroll.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) - + scroll.add_with_viewport(self.box_encuesta) - + toolbar_encuesta = ToolbarEncuesta() - + base_box.pack_start(scroll, True, True, 0) base_box.pack_start(toolbar_encuesta, False, False, 0) - + self.pack2(base_box, resize = True, shrink = True) - + self.show_all() - + self.scroll_list.hide() self.box_encuesta.hide() - + toolbar_encuesta.connect('accion', self.__accion_encuesta) - + def __accion_encuesta(self, widget, accion): """ Pasa la vista de un grupo de preguntas a otro según valor de accion. """ - + index_visible = 0 - + grupos = self.box_encuesta.get_children() - + for child in grupos: if child.get_visible(): index_visible = grupos.index(child) break - - if accion == 'Anterior': + + if accion == 'Pag. Anterior': if index_visible > 0: map(self.__desactivar, grupos) map(self.__activar, [grupos[index_visible - 1]]) - - elif accion == 'Siguiente': + + elif accion == 'Pag. Siguiente': if index_visible < len(grupos)-1: map(self.__desactivar, grupos) map(self.__activar, [grupos[index_visible + 1]]) - + def load_encuestados(self, encuestados): """ Carga una lista a encuestar. """ - + if not encuestados: return - + self.show() self.scroll_list.show_all() - + if self.lista: self.lista.destroy() - + self.encuestados = encuestados self.lista = Lista(self.encuestados) self.lista.connect('new-selection', self.__new_selection) self.scroll_list.add_with_viewport(self.lista) - + self.scroll_list.set_size_request(200,-1) - + self.__check_sensitive() - + def load_encuesta(self, encuesta): """ Carga una nueva Encuesta eliminando la anterior. Encuesta es un diccionario. """ - + if not encuesta: return - + self.show() self.box_encuesta.show_all() - + self.encuesta = encuesta self.dependencies = {} - + # Limpiar la interfaz. for child in self.box_encuesta.get_children(): child.destroy() - + # un grupo es un frame grupos = self.encuesta.keys() grupos.sort() - + for indice in grupos: # indice es el indice del grupo, Encuesta[indice] es el contenido # cada grupo es un diccionario con dos keys (name y fields) # name es el nombre del grupo == text del frame. fields son las preguntas - + grupo = Grupo(indice, self.encuesta[indice]) self.box_encuesta.pack_start(grupo, False, True, 5) - + grupo.connect('new', self.__change) grupo.connect('text', self.__emit_text) grupo.connect('dependencies', self.__set_dependencies) - + self.__check_sensitive() - + grupos = self.box_encuesta.get_children() map(self.__desactivar, grupos) map(self.__activar, [grupos[0]]) - + def __emit_text(self, widget, id_pregunta, id_opcion, text): """ Cuando se ingresa texto en una opción del tipo Entry. (caso particular). """ - + encuestado = self.__get_encuestado() - + self.emit( 'text', encuestado, widget.indice, id_pregunta, id_opcion, text) - + def __change(self, widget, pregunta, activan, desactivan): """ Cuando se contesta una pregunta se checkean las dependencias y se guardan los datos. """ - + encuestado = self.__get_encuestado() - + grupo_name = widget.grupo['name'] dict_pregunta = pregunta.pregunta.copy() dict_pregunta['default'] = list(activan) # list(pregunta.widget_obtions.default) - + indice_grupo = widget.indice indice_pregunta = pregunta.indice - + self.emit('new', encuestado, indice_grupo, grupo_name, indice_pregunta, dict_pregunta) - + activar = [] desactivar = [] - + for key in activan: if key in self.dependencies.values(): for item in self.dependencies.items(): if item[1] == key: activar.append(item[0]) - + for key in desactivan: if key in self.dependencies.values(): for item in self.dependencies.items(): if item[1] == key: desactivar.append(item[0]) - + map(self.__activar, activar) map(self.__desactivar, desactivar) - + def __get_encuestado(self): """ Devuelve lista con datos del encuestado seleccionado. """ - + modelo, iter = self.lista.treeselection.get_selected() - + encuestado = [] - + for index in range(0, 8): encuestado.append(modelo.get_value(iter, index)) - + return encuestado - + def __new_selection(self, widget, encuestado): """ Cuando el usuario cambia de Encuestado. """ - + self.emit('new-selection', encuestado) - + def __set_dependencies(self, widget, dependencies): """ Al crearse un grupo, Recibe la lista de sus preguntas que tienen dependencia a una respuesta particular en otra pregunta y la desactiva. """ - + for pregunta in dependencies: self.dependencies[pregunta] = pregunta.pregunta['dependence'] - + def __activar(self, widget): - + widget.set_visible(True) - + def __desactivar(self, widget): - + widget.set_visible(False) - + def __check_sensitive(self): - + if not self.encuesta: self.box_encuesta.hide() - + elif self.encuesta: self.box_encuesta.show_all() - + if not self.lista: self.scroll_list.hide() - + elif self.lista: self.scroll_list.show_all() - + if self.encuesta and self.lista: self.set_sensitive(True) - + else: self.set_sensitive(False) - + def update(self, dict): """ Cuando se selecciona un usuario que ha @@ -297,220 +297,225 @@ class Panel(Gtk.Paned): actualiza la interfaz gráfica de la misma con esos valores. """ - + self.load_encuesta(self.encuesta) - + for child in self.box_encuesta.get_children(): if not child.indice in dict.keys(): continue child.update(dict[child.indice]) - + activadas = [] - + for key in dict.keys(): for pregunta in dict[key]['fields'].keys(): for default in dict[key]['fields'][pregunta]['default']: activadas.append(default) - + for child in self.box_encuesta.get_children(): for pregunta in child.box_preguntas.get_children(): - + if pregunta.pregunta.get('dependence', None): - + if pregunta.pregunta['dependence'] in activadas: pregunta.set_visible(True) - + else: pregunta.set_visible(False) - + else: pregunta.set_visible(True) - + class My_FileChooser(Gtk.FileChooserDialog): """ Selector de Archivos para poder cargar archivos desde cualquier dispositivo o directorio. """ - + __gsignals__ = { 'load':(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT,))} - + def __init__(self, parent_window = None, action_type = None, filter_type = None, title = None): - + Gtk.FileChooserDialog.__init__(self, parent = parent_window, action = action_type, flags = Gtk.DialogFlags.MODAL, title = title) - + self.set_default_size( 640, 480 ) self.set_select_multiple(False) self.set_current_folder_uri("file:///%s" % WORKPATH) - + if filter_type != None: filter = Gtk.FileFilter() filter.set_name(filter_type) filter.add_mime_type(filter_type) self.add_filter(filter) - + hbox = Gtk.Box(orientation = Gtk.Orientation.HORIZONTAL) - + texto = "" if action_type == Gtk.FileChooserAction.OPEN: texto = "Abrir" - + elif action_type == Gtk.FileChooserAction.SAVE: texto = "Guardar" - + abrir = Gtk.Button(texto) salir = Gtk.Button("Salir") - + hbox.pack_end(salir, True, True, 5) hbox.pack_end(abrir, True, True, 5) - + self.set_extra_widget(hbox) - + salir.connect("clicked", self.salir) abrir.connect("clicked", self.abrir) - + self.show_all() - + def abrir(self, widget): - + self.emit('load', self.get_filename()) self.salir(None) def salir(self, widget): - + self.destroy() - + class Lista(Gtk.TreeView): """ Lista Dinámica de encuestados. """ - + __gsignals__ = { "new-selection":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, ))} - + def __init__(self, encuestados): - + encabezado = encuestados[0] encuestados = encuestados[1:] - + Gtk.TreeView.__init__(self) - + self.set_property("rules-hint", True) self.set_headers_clickable(True) self.set_headers_visible(True) self.valor_select = None - + strings = [] - + for x in encabezado: strings.append(GObject.TYPE_STRING) - + self.modelo = Gtk.ListStore(*strings) - + for item in encabezado: - + + visible = False + + if item == "CI" or item == "NOMBRE": + visible = True + self.append_column( self.construir_columa( item, encabezado.index(item), - True)) - + visible)) + self.treeselection = self.get_selection() - + self.treeselection.set_select_function( self.selecciones, self.modelo) - + self.set_model(self.modelo) self.show_all() - + self.add_encuestados(encuestados) - + def selecciones(self, treeselection, model, path, is_selected, listore): """ Cuando se selecciona un item en la lista. """ - + iter = model.get_iter(path) - + encuestado = "" - + for index in range(0, 8): encuestado += "%s " % model.get_value(iter, index) - + encuestado = encuestado.strip() - + if not is_selected and self.valor_select != encuestado: self.valor_select = encuestado self.emit('new-selection', self.valor_select) - + return True - + def construir_columa(self, text, index, visible): - + render = Gtk.CellRendererText() columna = Gtk.TreeViewColumn(text, render, text=index) columna.set_sort_column_id(index) columna.set_property('visible', visible) columna.set_property('resizable', False) columna.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) - + return columna - + def add_encuestados(self, encuestados): """ Recibe lista de: encuestados y Comienza secuencia de agregado. """ - + GObject.idle_add(self.run_add_encuestado, encuestados) - + def run_add_encuestado(self, encuestados): """ Agrega los items a la lista, uno a uno, actualizando. """ - + if not encuestados: - + if not self.valor_select: self.seleccionar_primero() - + return - + encuestado = encuestados[0] - + self.modelo.append( encuestado ) - + encuestados.remove(encuestado) - + GObject.idle_add(self.run_add_encuestado, encuestados) def seleccionar_primero(self, widget = None): - + self.treeselection.select_path(0) - + class Grupo(Gtk.Frame): """ Frame para grupo de Preguntas de la encuesta. - + Un grupo es: '0': { 'name': 'group 0', 'fields': { . . . => Preguntas} } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, @@ -520,64 +525,64 @@ class Grupo(Gtk.Frame): "text":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING))} - + def __init__(self, indice_grupo, grupo): - + Gtk.Frame.__init__(self) - + self.indice = indice_grupo # indice del grupo en la encuesta self.grupo = grupo # Diccionario del grupo en la encuesta - + self.set_label(self.grupo['name']) - + self.box_preguntas = Gtk.VBox() self.add(self.box_preguntas) - + preguntas = self.grupo['fields'] dependencies = [] - + keys = preguntas.keys() keys.sort() - + for indice in keys: pregunta = Pregunta(indice, preguntas[indice]) self.box_preguntas.pack_start(pregunta, False, True, 3) pregunta.connect('new', self.change) pregunta.connect('text', self.emit_text) - + if pregunta.pregunta.get('dependence', ''): dependencies.append(pregunta) - + self.show_all() - + if dependencies: GObject.idle_add(self.emit_dependencies, dependencies) - + def emit_text(self, widget, id_opcion, text): """ Cuando se ingresa texto en una opción del tipo Entry. (caso particular). """ - + self.emit('text', widget.indice, id_opcion, text) - + def change(self, widget, activan, desactivan): """ Cuando se contesta una pregunta, checkea las dependencias y se guardan los datos. """ - + self.emit('new', widget, activan, desactivan) - + def emit_dependencies(self, dependencies): """ Luego de creado el grupo, se emite la lista de preguntas con dependencia a respuestas en otras preguntas. """ - + self.emit('dependencies', dependencies) - + def update(self, dict): """ Cuando se selecciona un usuario que ha @@ -585,19 +590,19 @@ class Grupo(Gtk.Frame): actualiza la interfaz gráfica de la misma con esos valores. """ - + for child in self.box_preguntas.get_children(): - + # Si se respondió esta pregunta if child.indice in dict['fields'].keys(): child.update(dict['fields'][child.indice]) - + class Pregunta(Gtk.HBox): """ Box con Pregunta. - + Una pregunta es: - + { '0': { 'widget_type': 'RadioButton', @@ -610,7 +615,7 @@ class Pregunta(Gtk.HBox): } } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, @@ -618,64 +623,64 @@ class Pregunta(Gtk.HBox): "text":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING, GObject.TYPE_STRING))} - + def __init__(self, indice_pregunta, pregunta): - + Gtk.HBox.__init__(self) - + self.indice = indice_pregunta self.pregunta = pregunta - + self.widget_obtions = None widget = self.pregunta['widget_type'] - + if widget == 'DropDownList': self.widget_obtions = Widget_DropDownList(self.pregunta['options']) - + elif widget == 'TextInput': self.widget_obtions = Widget_TextInput(self.pregunta['options']) self.widget_obtions.connect('text', self.emit_text) - + elif widget == 'MultipleCheckBox' or widget == 'ImageCheckBox': self.widget_obtions = Widget_MultipleCheckBox(self.pregunta['options']) - + elif widget == 'RadioButton' or widget == 'ImageRadioButton': self.widget_obtions = Widget_RadioButon(self.pregunta['options']) - + else: print "Widget no Considerado", widget - + label = Gtk.Label(self.pregunta['name']) - + pangoFont = Pango.FontDescription("10") - + label.modify_font(pangoFont) label.modify_fg(0, Gdk.Color(0, 0, 65000)) - + self.pack_start(label, False, True, 5) self.pack_end(self.widget_obtions, True, True, 0) - + self.show_all() - + self.widget_obtions.connect('new', self.change) - + def emit_text(self, widget, id_opcion, text): """ Cuando se ingresa texto en una opción del tipo Entry. (caso particular). """ - + self.emit('text', id_opcion, text) - + def change(self, widget, activan, desactivan): """ Cuando se Contesta una pregunta, se checkean las dependencia y se guardan los datos. """ - + self.emit('new', activan, desactivan) - + def update(self, dict): """ Cuando se selecciona un usuario que ha @@ -683,104 +688,104 @@ class Pregunta(Gtk.HBox): actualiza la interfaz gráfica de la misma con esos valores. """ - + self.widget_obtions.update(dict) class Widget_DropDownList(Gtk.ComboBoxText): """ Contenedor de opciones para respuestas posibles en una pregunta. - + Opciones es: - + 'options': { '00001': {'text': 'opcion 1'}, '00002': {'text': 'opcion 2'} } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT))} - + def __init__(self, options): - + Gtk.ComboBoxText.__init__(self) - + self.options = options self.updating = False - + for key in self.options.keys(): self.append_text(self.options[key]['text']) - + self.show_all() - + def do_changed(self): """ Cuando el usuario hace click sobre una opción, se checkean dependencias y se guardan los datos. """ - + if self.updating: return - + desactivan = [] activan = [] - + for key in self.options.keys(): if self.options[key]['text'] == self.get_active_text(): - + if not key in activan: activan.append(key) - + elif not self.options[key]['text'] == self.get_active_text(): - + if key in activan: activan.remove(key) - + if not key in desactivan: desactivan.append(key) - + self.emit('new', activan, desactivan) - + def update(self, dict): """ Cuando el usuario cambia de encuestado, actualiza sus respuestas en la pregunta. """ - + self.updating = True - + model = self.get_model() item = model.get_iter_first() - + count = 0 - + for default in dict['default']: - + while item: if model.get_value(item, 0) == \ dict['options'][default]['text']: - + self.set_active(count) self.updating = False return - + item = model.iter_next(item) count += 1 - + self.updating = False - + class Widget_TextInput(Gtk.Entry): """ Contenedor para entrada de texto para respuesta a una pregunta. - + Opciones es: - + 'options':{ '00001':{'text': ''} } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, @@ -788,307 +793,307 @@ class Widget_TextInput(Gtk.Entry): "text":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING, GObject.TYPE_STRING))} - + def __init__(self, options): - + Gtk.Entry.__init__(self) - + self.options = options - + self.updating = False - + key = self.options.keys()[0] self.set_text(self.options[key]['text']) - + self.show_all() - + def do_key_release_event(self, void): """ Cuando el usuario ingresa algún valor en la opción, se checkean dependencias. """ - + if self.updating: return - + desactivan = [] activan = [] - + key = self.options.keys()[0] text = self.get_text() - + if text: activan.append(key) - + elif not text: desactivan.append(key) - + self.emit('new', activan, desactivan) self.emit('text', key, text) - + def update(self, dict): """ Cuando el usuario cambia de encuestado, actualiza sus respuestas en la pregunta. """ - + self.updating = True - + key = self.options.keys()[0] - + if 'newtext' in self.options[key].keys(): self.set_text(self.options[key]['newtext']) - + else: self.set_text(self.options[key]['text']) - + self.updating = False class Widget_RadioButon(Gtk.ButtonBox): """ Contenedor de opciones para respuestas posibles en una pregunta. - + Opciones es: - + 'options': { '00001': {'text': 'opcion 1'}, '00002': {'text': 'opcion 2'} } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT))} - + def __init__(self, options): - + Gtk.ButtonBox.__init__(self) - + self.options = options self.updating = False - + grupo = None - + keys = self.options.keys() keys.sort() - + for key in keys: - + radio = MyRadioButton(key) - + text = self.options[key].get('text', '') imagen = self.options[key].get('img', '') - + if text: radio.set_label(text) - + if imagen: loader = GdkPixbuf.PixbufLoader() image_string = base64.b64decode(imagen) loader.write(image_string) loader.close() - + pixbuf = loader.get_pixbuf().scale_simple( 80, 80, GdkPixbuf.InterpType.BILINEAR) - + radio.set_image(Gtk.Image.new_from_pixbuf(pixbuf)) - + if grupo == None: grupo = radio - + if keys.index(key) != 0: radio.join_group(grupo) - + self.pack_start(radio, False, False, 3) - + radio.connect('toggled', self.change) - + self.show_all() - + def change(self, widget): """ Cuando el usuario hace click sobre una opción, se checkean dependencias y se guardan los datos. """ - + if self.updating: return - + options = self.get_children() - + desactivan = [] activan = [] - + for child in options: - + if child.get_active(): activan.append(child.indice) - + elif not child.get_active(): desactivan.append(child.indice) - + self.emit('new', activan, desactivan) - + def update(self, dict): """ Cuando el usuario cambia de encuestado, actualiza sus respuestas en la pregunta. """ - + self.updating = True - + options = self.get_children() - + for child in options: if child.indice in dict['default']: child.set_active(True) - + else: child.set_active(False) - + self.updating = False - + class Widget_MultipleCheckBox(Gtk.Table): """ Contenedor de opciones para respuestas posibles en una pregunta. - + Opciones es: - + 'options': { '00001': {'text': 'opcion 1'}, '00002': {'text': 'opcion 2'} } """ - + __gsignals__ = { "new":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT))} - + def __init__(self, options): - + columns = 2 - + rows = int(len(options)/columns) - + while rows*columns < int(len(options)): rows += 1 - + Gtk.Table.__init__( self, rows = rows, columns = columns, homogeneous = True) - + self.options = options self.updating = False - + keys = self.options.keys() keys.sort() - + col = 0 row = 0 - + for key in keys: - + check = MyCheckButton(key) - + text = self.options[key].get('text', '') imagen = self.options[key].get('img', '') - + if text: check.set_label(text) - + if imagen: loader = GdkPixbuf.PixbufLoader() image_string = base64.b64decode(imagen) loader.write(image_string) loader.close() - + pixbuf = loader.get_pixbuf().scale_simple( 80, 80, GdkPixbuf.InterpType.BILINEAR) - + check.set_image(Gtk.Image.new_from_pixbuf(pixbuf)) - + self.attach_defaults(check, col, col+1, row, row+1) - + col += 1 - + if col == columns: col = 0 row += 1 - + check.connect('toggled', self.change) - + self.show_all() - + def change(self, widget): """ Cuando el usuario hace click sobre una opción, se checkean dependencias y se guardan los datos. """ - + if self.updating: return - + options = self.get_children() - + desactivan = [] activan = [] - + for child in options: - + if child.get_active(): activan.append(child.indice) - + elif not child.get_active(): desactivan.append(child.indice) - + self.emit('new', activan, desactivan) - + def update(self, dict): """ Cuando el usuario cambia de encuestado, actualiza sus respuestas en la pregunta. """ - + self.updating = True - + options = self.get_children() - + for child in options: if child.indice in dict['default']: child.set_active(True) - + else: child.set_active(False) - + self.updating = False - + class MyCheckButton(Gtk.CheckButton): - + def __init__(self, indice): - + Gtk.CheckButton.__init__(self) - + self.indice = indice - + self.show_all() - + class MyRadioButton(Gtk.RadioButton): - + def __init__(self, indice): - + Gtk.RadioButton.__init__(self) - + self.indice = indice - + self.show_all() - + class My_Alert_Dialog(Gtk.Dialog): """ Dialogo que alerta al usuario sobre una acción que obliga a perder los datos. """ - + def __init__(self, parent_window = None, label = ""): - + Gtk.Dialog.__init__( self, title = "ATENCION !", parent = parent_window, @@ -1096,49 +1101,50 @@ class My_Alert_Dialog(Gtk.Dialog): buttons = [ "Proceder", Gtk.ResponseType.ACCEPT, "Cancelar", Gtk.ResponseType.CANCEL]) - + label = Gtk.Label(label) label.show() - + self.vbox.pack_start(label, True, True, 0) - + class ToolbarEncuesta(Gtk.Toolbar): - + __gsignals__ = { "accion":(GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, (GObject.TYPE_STRING,))} - + def __init__(self): - + Gtk.Toolbar.__init__(self) - + separador = Gtk.SeparatorToolItem() separador.props.draw = False separador.set_size_request(0, -1) separador.set_expand(True) - + self.insert(separador, -1) - + item = Gtk.ToolItem() item.set_expand(False) - button = Gtk.Button("Anterior") - button.set_tooltip_text("Ir al Grupo Anterior") + button = Gtk.Button("Pag. Anterior") + button.set_tooltip_text("Ir a la Página de Preguntas Anterior") button.connect("clicked", self.__button_clicked) button.show() item.add(button) self.insert(item, -1) - + item = Gtk.ToolItem() item.set_expand(False) - button = Gtk.Button("Siguiente") - button.set_tooltip_text("Ir al Grupo Siguiente") + button = Gtk.Button("Pag. Siguiente") + button.set_tooltip_text("Ir a la Siguiente Página de Preguntas") button.connect("clicked", self.__button_clicked) button.show() item.add(button) self.insert(item, -1) - + self.show_all() - + def __button_clicked(self, widget): - + self.emit('accion', widget.get_label()) +
\ No newline at end of file |