Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRogelio Mita <rogeliomita@activitycentral.com>2013-07-31 18:19:07 (GMT)
committer Rogelio Mita <rogeliomita@activitycentral.com>2013-07-31 18:19:07 (GMT)
commitaeee06bc37887b01544c02f5f6f2d8ed6e7593d8 (patch)
tree01500b1ec1ed2d569b51d329748a6d09c6ccea35
parent3b7a325f044c2de253ad797d3674c738d762479a (diff)
Bug Fix: options alignment between questions (issue 4157)
-rw-r--r--CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py97
1 files changed, 49 insertions, 48 deletions
diff --git a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py
index ff57da5..b808f15 100644
--- a/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py
+++ b/CeibalEncuesta/gtk2/CeibalEncuesta/Widgets.py
@@ -36,7 +36,7 @@ WORKPATH = os.path.join(HOME, "CeibalEncuesta")
BACKUP_PATH = os.path.join(HOME, "Documentos")
if not os.path.exists(BACKUP_PATH):
BACKUP_PATH = WORKPATH
-
+
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
ICON = PROJECT_ROOT + '/Iconos/ceibal.png'
NEXT_PAGE_ACTIVE = PROJECT_ROOT + "/Iconos/next-page-active.png"
@@ -904,13 +904,13 @@ class Grupo(gtk.Frame):
gobject.TYPE_PYOBJECT))}
def __init__(self, indice_grupo, grupo):
-
+
gtk.Frame.__init__(self, grupo.get('name', ''))
desc = pango.FontDescription(GRADO_FONT_SIZE)
desc.set_weight(pango.WEIGHT_BOLD)
self.modify_font(desc)
-
+
self.indice = indice_grupo # indice del grupo en la encuesta
self.grupo = grupo.copy() # Diccionario del grupo en la encuesta
@@ -1037,7 +1037,7 @@ class Pregunta(gtk.VBox):
label.modify_font(pangoFont)
label.set_line_wrap(True)
label.set_size_request(700, -1)
-
+
# --- QUESTION TITLE INDENT: horizontal alignment
halign = gtk.Alignment(0, 0, 0, 0)
halign.set_padding(25, 25, 50, 0)
@@ -1059,7 +1059,8 @@ class Pregunta(gtk.VBox):
# --- END QUESTION TITLE INDENT
# --- OPTIONS INDENT: horizontal alignment for question's options
- halign = gtk.Alignment(0.2, 0.1, 0, 0)
+ halign = gtk.Alignment(0, 0.1, 0, 0)
+ halign.set_padding(0, 0, 90, 0)
# Vertical list of question's options
vbbox = gtk.VButtonBox()
@@ -1157,10 +1158,10 @@ class Widget_DropDownList(gtk.ComboBox):
for key in self.options.keys():
id = int(self.options[key]["order"])
order[id] = key
-
+
indices = order.keys()
indices.sort()
-
+
for id in indices:
key = order[id]
self.append_text(self.options[key]["text"])
@@ -1294,20 +1295,20 @@ class Widget_TextInput(gtk.Entry):
self.has_focus = False
self.show_all()
-
+
def is_focused(self):
return self.has_focus
-
+
def __out_focus(self, widget, event):
-
+
if not widget.is_focus():
self.get_toplevel().save_text()
-
+
else:
widget.select_region(0, -1)
-
+
widget.has_focus = False
-
+
def __on_entry_clicked(self, widget, event, data=None):
if not widget.is_focused() and event.type == gtk.gdk.BUTTON_RELEASE:
widget.select_region(0, -1)
@@ -1432,15 +1433,15 @@ class Widget_RadioButon(gtk.VButtonBox):
self.updating = False
grupo = None
-
+
order = {}
for key in self.options.keys():
id = int(self.options[key]["order"])
order[id] = key
-
+
indices = order.keys()
indices.sort()
-
+
for id in indices:
key = order[id]
radio = MyRadioButton(key)
@@ -1567,19 +1568,19 @@ class Widget_MultipleCheckBox(gtk.VButtonBox):
self.options = options.copy()
self.updating = False
-
+
order = {}
for key in self.options.keys():
id = int(self.options[key]["order"])
order[id] = key
-
+
indices = order.keys()
indices.sort()
-
+
for id in indices:
key = order[id]
check = MyCheckButton(key, self.options[key].get("none", False))
-
+
text = self.options[key].get("text", None)
imagen = self.options[key].get("img", "")
@@ -1626,34 +1627,34 @@ class Widget_MultipleCheckBox(gtk.VButtonBox):
if self.updating: return
options = self.get_children()
-
+
activan = []
-
+
if widget.none and widget.get_active():
### Desactivar todas las opciones que no sean "ninguna."
for child in options:
child = child.get_button()
-
+
if child == widget:
activan = [child.indice]
continue
-
+
child.set_active(False)
-
+
elif not widget.none and widget.get_active():
### Desactivar la opción "ninguna."
for child in options:
child = child.get_button()
-
+
if child.none and child.get_active():
child.set_active(False)
-
+
else:
if child.get_active():
activan.append(child.indice)
-
+
self.emit("new", activan)
-
+
def update(self, dict):
"""
Cuando el usuario cambia de encuestado,
@@ -1722,7 +1723,7 @@ class MyContainer(gtk.HBox):
def get_button(self):
return self.button
-
+
def get_label(self):
return self.text_label
@@ -1736,7 +1737,7 @@ class MyCheckButton(gtk.CheckButton):
if none == "true": none = True
if none == "false": none = False
self.none = none
-
+
self.show_all()
class MyRadioButton(gtk.RadioButton):
@@ -1815,31 +1816,31 @@ class ToolbarEncuesta(gtk.HBox):
self.show_all()
def __button_clicked(self, widget):
-
+
if widget == self.siguiente:
if not self.siguiente.active:
dialogo = gtk.Dialog(parent = self.get_toplevel(),
flags = gtk.DIALOG_MODAL,
buttons = ("OK", gtk.RESPONSE_ACCEPT))
-
+
dialogo.set_size_request(450, 200)
dialogo.set_border_width(15)
-
+
label = gtk.Label("Todavía hay Preguntas sin Responder.")
label.show()
-
+
dialogo.vbox.pack_start(label, True, True, 0)
-
+
dialogo.run()
-
+
dialogo.destroy()
-
+
self.emit("accion", widget.accion)
panel = self.get_toplevel().panel
if len(panel.visible_questions()) == 0:
self.__button_clicked(widget)
-
+
class PageButton(gtk.Button):
__gsignals__ = {
@@ -1886,7 +1887,7 @@ class PageButton(gtk.Button):
self.connect("enter", self.__button_event, "enter")
self.connect("leave", self.__button_event, "leave")
self.connect("update_status", self.__update_status)
-
+
def __update_status(self, widget, panel):
new_img = NEXT_PAGE_ACTIVE
@@ -1912,7 +1913,7 @@ class PageButton(gtk.Button):
self.emit("enter")
def __button_event(self, widget, img_file=None):
-
+
if not self.active: return
if img_file is None: return
@@ -2380,9 +2381,9 @@ class Wizard(gtk.Dialog):
valido = G.csv_validate(self.csv_file)
return valido
-
+
def validate_json_file(self):
-
+
valido = True
if self.json_file:
@@ -2394,20 +2395,20 @@ class Wizard(gtk.Dialog):
archivo = codecs.open(self.json_file, "r", "utf-8")
enc = json.JSONDecoder("utf-8").decode(archivo.read())
-
+
keys = enc.keys()
-
+
for key in ["pollster_id", "poll_name", "poll_id", "groups", "pollster_username"]:
if not key in keys:
valido = False
break
-
+
else:
valido = False
-
+
else:
valido = False
-
+
return valido
def validate_tmp_file(self):