Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2013-07-30 23:12:29 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-09-02 17:50:00 (GMT)
commit2b138901d985112af4dca77c85015d72fbc7d678 (patch)
tree8c3db60a2a9965295a990e939f14885c6813278e
parentad407f2eb6c765a165372834ceea9f2195c3d908 (diff)
Reemplazar la funciĆ³n _buildcanvas por la clase NewPollCanvas.
-rw-r--r--Widgets.py108
-rw-r--r--poll.py13
2 files changed, 116 insertions, 5 deletions
diff --git a/Widgets.py b/Widgets.py
new file mode 100644
index 0000000..510c9db
--- /dev/null
+++ b/Widgets.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Widgets.py por:
+# Flavio Danesse <fdanesse@gmail.com>
+# CeibalJAM! - Uruguay
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#import os
+from gettext import gettext as _
+
+from gi.repository import Gtk
+
+class NewPollCanvas(Gtk.Box):
+
+ def __init__(self, poll, editing=False, highlight=[]):
+
+ Gtk.Box.__init__(self, orientation = Gtk.Orientation.VERTICAL)
+
+ """
+ Show the canvas to set up a new poll.
+
+ editing is False to start a new poll, or
+ True to edit the current poll
+
+ highlight is a list of strings denoting items failing validation.
+ """
+
+ #self._current_view = 'build'
+
+ label = Gtk.Label()
+ label.set_markup('<big><b>%s</b></big>' % _('Build a Poll'))
+ self.pack_start(label, False, False, 10)
+
+ hbox = Gtk.HBox()
+ hbox.pack_start(Gtk.Label(_('Poll Title:')), False, False, 10)
+ entrybox = Gtk.Entry()
+ entrybox.set_text(poll.title)
+ #entrybox.connect('changed', self._entry_activate_cb, 'title')
+ hbox.pack_start(entrybox, True, True, 10)
+ self.pack_start(hbox, False, False, 10)
+
+ hbox = Gtk.HBox()
+ hbox.pack_start(Gtk.Label(_('Question:')), False, False, 10)
+ entrybox = Gtk.Entry()
+ entrybox.set_text(poll.question)
+ #entrybox.connect('changed', self._entry_activate_cb, 'question')
+ hbox.pack_start(entrybox, True, True, 10)
+ self.pack_start(hbox, False, False, 10)
+
+ hbox = Gtk.HBox()
+ hbox.pack_start(Gtk.Label(_('Number of votes to collect:')),
+ False, False, 10)
+ entrybox = Gtk.Entry()
+ entrybox.set_text(str(poll.maxvoters))
+ #entrybox.connect('changed', self._entry_activate_cb, 'maxvoters')
+ hbox.pack_start(entrybox, True, True, 10)
+ self.pack_start(hbox, False, False, 10)
+
+ for choice in poll.options.keys():
+ hbox = Gtk.HBox()
+ hbox.pack_start(Gtk.Label(_('Answer %d:') % (choice + 1)),
+ False, False, 10)
+ entrybox = Gtk.Entry()
+ entrybox.set_text(poll.options[choice])
+ #entrybox.connect('changed', self._entry_activate_cb, str(choice))
+ hbox.pack_start(entrybox, True, True, 10)
+ '''
+ if self._use_image:
+ if self._already_loaded_image_in_answer(choice):
+ button = Gtk.Button(_("Change Image"))
+ hbox.pack_start(button, True, False, 10)
+ self._show_image_thumbnail(hbox, choice)
+
+ else:
+ button = Gtk.Button(_("Add Image"))
+ hbox.pack_start(button, True, False, 10)
+
+ button.connect('clicked', self._button_choose_image_cb,
+ str(choice), hbox)'''
+
+ self.pack_start(hbox, False, False, 10)
+
+ # PREVIEW & SAVE buttons
+ hbox = Gtk.HBox()
+ button = Gtk.Button(_("Step 1: Preview"))
+ #button.connect('clicked', self._button_preview_cb)
+ hbox.pack_start(button, True, True, 10)
+ button = Gtk.Button(_("Step 2: Save"))
+ #button.connect('clicked', self._button_save_cb)
+ hbox.pack_start(button, True, True, 10)
+
+ self.pack_start(hbox, False, False, 10)
+
+ self.show_all()
diff --git a/poll.py b/poll.py
index 69305c1..2ae35d5 100644
--- a/poll.py
+++ b/poll.py
@@ -91,6 +91,9 @@ IMAGE_WIDTH = 100
IMAGE_THUMBNAIL_HEIGHT = 80
IMAGE_THUMBNAIL_WIDTH = 80
'''
+
+from Widgets import NewPollCanvas
+
class PollBuilder(activity.Activity):
"""
Sugar activity for polls
@@ -749,7 +752,7 @@ class PollBuilder(activity.Activity):
#self.current_vote = None
- self.set_canvas(self.__build_canvas())
+ self.set_canvas(NewPollCanvas(self._poll))
'''
def button_edit_clicked(self, button):
@@ -849,7 +852,7 @@ class PollBuilder(activity.Activity):
else:
return False'''
-
+ '''
def __build_canvas(self, editing=False, highlight=[]):
"""
Show the canvas to set up a new poll.
@@ -900,7 +903,7 @@ class PollBuilder(activity.Activity):
entrybox.set_text(self._poll.options[choice])
#entrybox.connect('changed', self._entry_activate_cb, str(choice))
hbox.pack_start(entrybox, True, True, 10)
- '''
+ """
if self._use_image:
if self._already_loaded_image_in_answer(choice):
button = Gtk.Button(_("Change Image"))
@@ -912,7 +915,7 @@ class PollBuilder(activity.Activity):
hbox.pack_start(button, True, False, 10)
button.connect('clicked', self._button_choose_image_cb,
- str(choice), hbox)'''
+ str(choice), hbox)"""
canvasbox.pack_start(hbox, False, False, 10)
@@ -929,7 +932,7 @@ class PollBuilder(activity.Activity):
canvasbox.show_all()
- return canvasbox
+ return canvasbox'''
'''
def _options_canvas(self, editing=False, highlight=[]):
"""