Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mayer <christian.mayer@student.tugraz.at>2010-01-11 13:42:22 (GMT)
committer Christian Mayer <christian.mayer@student.tugraz.at>2010-01-11 13:42:22 (GMT)
commita5e771edeb19a13c1ffeb20d504e4440c3d1854e (patch)
tree1f0ebfda1db8ace3483370883e89a80000d97269
parent4545e74816fdbf60ff7f98ae4bb101eb106d935a (diff)
begin feedback table
-rwxr-xr-xReckonPrimer.activity/display.py138
-rw-r--r--ReckonPrimer.activity/views/__init__.py0
-rw-r--r--ReckonPrimer.activity/views/feedback_view.py134
-rw-r--r--ReckonPrimer.activity/views/rhs_view_manager.py19
4 files changed, 174 insertions, 117 deletions
diff --git a/ReckonPrimer.activity/display.py b/ReckonPrimer.activity/display.py
index a2a26ee..022e5c0 100755
--- a/ReckonPrimer.activity/display.py
+++ b/ReckonPrimer.activity/display.py
@@ -5,12 +5,12 @@ import gtk
import pygtk
import pango
import time
-import gobject
-from timer import Timer
-from sugar import profile
+
from sugar.graphics import style
from sugar.activity import activity
+from views.rhs_view_manager import RHSViewManager
+
class Display:
"""
Definition and manipulation of all GUI-elemts.
@@ -21,6 +21,7 @@ class Display:
def __init__(self, window):
self._permanent_gui_elements(window)
self.errors = 0
+ self.false_count = 0 # TODO move
self._ex = None # needed for feedback_table etc
# TODO: imprive information hiding
self._sett = None # setting updated by callbacks during input
@@ -90,32 +91,25 @@ class Display:
# 3 tables as overlays with same 15 lines and 6 columns
self.settings_table = gtk.Table (14, 9, True)
self.collection_table = gtk.Table(14, 9, True)
- self.feedback_table = gtk.Table (14, 9, True)
+ # self.feedback_view = Feedback(self, 42) # TODO totoal_number_calcs
+ # self.feedback_table = self.feedback_view.table
+ __rhs_view_manager = RHSViewManager()
+
# Insert the 3 tables into the right half of the screen
- self.table.attach(self.settings_table, 1, 2, 0, 5)
- self.table.attach(self.collection_table,1, 2, 0, 5)
- self.table.attach(self.feedback_table, 1, 2, 0, 5)
+ #self.table.attach(self.settings_table, 1, 2, 0, 5)
+ #self.table.attach(self.collection_table,1, 2, 0, 5)
+ # self.table.attach(self.feedback_table, 1, 2, 0, 5)
+ self.table.attach(__rhs_view_manager, 1, 2, 0, 5)
# show all tables, scrolled_window already shown above
- self.settings_table_show() # treat uniformly <>!
- self.collection_table.show() # treat uniformly !
- self.feedback_table.show() # treat uniformly !
+ #self.settings_table_show() # treat uniformly <>!
+ #self.collection_table.show() # treat uniformly !
+ #self.feedback_table.show() # treat uniformly !
+ __rhs_view_manager.show('feedback')
self.table.show() # since all other tables have been inserted
- def update_time(self):
- minutes, seconds = divmod(self.stopwatch.elapsed, 60)
- if(minutes < 10 and seconds < 10):
- time = "0" + str(int(minutes)) + ":" + "0" + str(int(seconds))
- if(minutes > 9 and seconds > 9):
- time = str(int(minutes)) + ":" + str(int(seconds))
- if(minutes > 9 and seconds < 10):
- time = str(int(minutes)) + ":" + "0" + str(int(seconds))
- if(minutes < 10 and seconds > 10):
- time = "0" + str(int(minutes)) + ":" + str(int(seconds))
- self.stopwatch_label.set_label(time)
- self.stopwatch_label.queue_draw()
- return True
+
def settings_table_show(self): # rename to .._permanent
""" Initialize all permanent gui-elements in settings_table. """
@@ -143,97 +137,10 @@ class Display:
self.collection_table.show()
def feedback_table_show(self):
- """RENAME to draw_feedback_screen"""
- # Section for stopwatch
- self.stopwatch = Timer()
- self.stopwatch_label = gtk.Label("00:00")
- self.stopwatch_label.modify_font(pango.FontDescription("sans 16"))
- #self.feedback_table.attach(self.stopwatch_label, 3, 5, 12, 13)
- self.feedback_table.attach(self.stopwatch_label, 4, 6, 12, 13)
-
- # Section for nickname
- self.name = profile.get_nick_name()
- self.name_label = gtk.Label(self.name)
- self.name_label.modify_font(pango.FontDescription("sans 16"))
- #self.feedback_table.attach(self.name_label, 0, 6, 13, 14)
- self.feedback_table.attach(self.name_label, 0, 9, 13, 14)
-
- # Section for progress bar
- self.progressbar = gtk.ProgressBar(adjustment=None)
-
- # Color for progress bar
- style = self.progressbar.get_style()
- style.bg[gtk.STATE_PRELIGHT] = gtk.gdk.color_parse("green")
- self.progressbar.set_style (style)
- self.progressbar.set_fraction(0)
- self.feedback_table.attach(self.progressbar, 0, 9, 8, 9)
-
- # Labels for progress bar
- self.progress0 = gtk.Label("0")
- self.progress0.modify_font(pango.FontDescription("sans 16"))
- self.feedback_table.attach(self.progress0, 0, 1, 9, 10 )
-
- # Labels for status update
- self.correct_count = 0
- self.correct_counter = gtk.Label(str(self.correct_count))
- self.correct_counter.modify_font(pango.FontDescription("sans 16"))
-
- # Ugly code for label color
- attr = pango.AttrList()
- fg_color = pango.AttrForeground(0, 65535, 0, 0, 6)
- attr.insert(fg_color)
- self.correct_counter.set_attributes(attr)
-
- #self.feedback_table.attach(self.correct_counter, 2, 4, 9, 10 )
- self.feedback_table.attach(self.correct_counter, 3, 5, 9, 10 )
-
- self.false_count = 0
- self.false_counter = gtk.Label(str(self.false_count))
- self.false_counter.modify_font(pango.FontDescription("sans 16"))
-
- # Ugly code for label color
- attr = pango.AttrList()
- fg_color = pango.AttrForeground(0, 0, 65535, 0, 6)
- attr.insert(fg_color)
- self.false_counter.set_attributes(attr)
-
- #self.feedback_table.attach(self.false_counter, 2, 4, 10, 11 )
- self.feedback_table.attach(self.false_counter, 3, 5, 10, 11 )
-
- self.stopwatch_label.show()
- gobject.timeout_add(1000, self.update_time)
- self.name_label.show()
- self.progressbar.show()
- self.progress0.show()
- self.correct_counter.show()
- self.false_counter.show()
-
- self.total_calcs = self._ex.count()
- self.progress_total = gtk.Label(str(self.total_calcs))
- self.progress_total.modify_font(pango.FontDescription("sans 16"))
- #self.feedback_table.attach(self.progress_total, 5, 6, 9, 10 )
- self.feedback_table.attach(self.progress_total, 8, 9, 9, 10 )
- self.progress_total.show()
-
- self.sfb_butt = gtk.Button(None, gtk.STOCK_STOP)
- self.sfb_butt.connect("clicked", self.release_feedb_callback)
- self.feedback_table.attach(self.sfb_butt, 0, 9, 13, 14)
- self.sfb_alignment = self.sfb_butt.get_children()[0]
- self.sfb_hbox = self.sfb_alignment.get_children()[0]
- self.sfb_image, self.sfb_label = self.sfb_hbox.get_children()
- self.sfb_label.set_label("feedback_table")
- self.sfb_butt.show()
+ self.feedback_view.show()
def feedback_table_hide(self):
- self.progressbar.set_fraction(0)
- self.stopwatch_label.hide()
- self.name_label.hide()
- self.progressbar.hide()
- self.progress0.hide()
- self.correct_counter.hide()
- self.false_counter.hide()
- self.progress_total.hide()
- self.sfb_butt.hide()
+ self.feedback_view.hide()
def offer_setting(self,ex):
""" Prepare display for update of settings. """
@@ -259,7 +166,6 @@ class Display:
print('in display.release_sett_callback')
self._co.settings_done(self._ex._sett)
self.settings_table.hide()
- #self.collection_table.hide()
self.feedback_table_show()
@@ -304,7 +210,7 @@ class Display:
pass #otherwise feedback in protocol written twice: see entry.set_text("") below
else:
self.false_count = self.false_count + 1
- self.false_counter.set_text(str(self.false_count))
+ self.feedback_view.update_error_counter(self.false_count)
self.errors = self.errors + 1
widget.set_text("")
self.protocol(proterr, self.errors, 'XXX')
@@ -361,9 +267,7 @@ class Display:
self.stopwatch.stop()
def show_progress(self):
- self.progressbar.set_fraction(self.progressbar.get_fraction()+(float(1)/float(self.total_calcs)))
- self.correct_count = self.correct_count + 1
- self.correct_counter.set_text(str(self.correct_count))
+ self.feedback_view.update_progressbar()
self.calc_table.destroy()
def offer_coll_to_learner(self, collect):
diff --git a/ReckonPrimer.activity/views/__init__.py b/ReckonPrimer.activity/views/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ReckonPrimer.activity/views/__init__.py
diff --git a/ReckonPrimer.activity/views/feedback_view.py b/ReckonPrimer.activity/views/feedback_view.py
new file mode 100644
index 0000000..39d42c0
--- /dev/null
+++ b/ReckonPrimer.activity/views/feedback_view.py
@@ -0,0 +1,134 @@
+import gtk
+import pango
+from timer import Timer
+import gobject
+
+from sugar import profile # TODO remove dep.
+
+class FeedbackView:
+
+ def __init__(self):
+ self.total_number_of_calculations = 99
+ self.table = gtk.Table(14, 9, True)
+ self.build_view()
+
+
+ def update_time(self):
+ minutes, seconds = divmod(self.stopwatch.elapsed, 60)
+ if(minutes < 10 and seconds < 10):
+ time = "0" + str(int(minutes)) + ":" + "0" + str(int(seconds))
+ if(minutes > 9 and seconds > 9):
+ time = str(int(minutes)) + ":" + str(int(seconds))
+ if(minutes > 9 and seconds < 10):
+ time = str(int(minutes)) + ":" + "0" + str(int(seconds))
+ if(minutes < 10 and seconds > 10):
+ time = "0" + str(int(minutes)) + ":" + str(int(seconds))
+ self.stopwatch_label.set_label(time)
+ self.stopwatch_label.queue_draw()
+ return True
+
+ # TODO
+ def update_error_counter(self, counter):
+ self.false_counter.set_text(str(counter))
+
+ def update_progressbar(self):
+ self.progressbar.set_fraction(self.progressbar.get_fraction()+(float(1)/float(self.total_number_of_calculations)))
+ self.correct_count = self.correct_count + 1
+ self.correct_counter.set_text(str(self.correct_count))
+
+ def hide(self):
+ self.table.hide()
+ # self.progressbar.set_fraction(0)
+ # self.stopwatch_label.hide()
+ # self.name_label.hide()
+ # self.progressbar.hide()
+ # self.progress0.hide()
+ # self.correct_counter.hide()
+ # self.false_counter.hide()
+ # self.progress_total.hide()
+ # self.sfb_butt.hide()
+
+ def show(self):
+ self.table.show()
+
+ def build_view(self):
+ """RENAME to draw_feedback_screen"""
+ # Section for stopwatch
+ self.stopwatch = Timer()
+ self.stopwatch_label = gtk.Label("00:00")
+ self.stopwatch_label.modify_font(pango.FontDescription("sans 16"))
+ #self.table.attach(self.stopwatch_label, 3, 5, 12, 13)
+ self.table.attach(self.stopwatch_label, 4, 6, 12, 13)
+
+ # Section for nickname
+ self.name = profile.get_nick_name()
+ self.name_label = gtk.Label(self.name)
+ self.name_label.modify_font(pango.FontDescription("sans 16"))
+ #self.table.attach(self.name_label, 0, 6, 13, 14)
+ self.table.attach(self.name_label, 0, 9, 13, 14)
+
+ # Section for progress bar
+ self.progressbar = gtk.ProgressBar(adjustment=None)
+
+ # Color for progress bar
+ style = self.progressbar.get_style()
+ style.bg[gtk.STATE_PRELIGHT] = gtk.gdk.color_parse("green")
+ self.progressbar.set_style (style)
+ self.progressbar.set_fraction(0)
+ self.table.attach(self.progressbar, 0, 9, 8, 9)
+
+ # Labels for progress bar
+ self.progress0 = gtk.Label("0")
+ self.progress0.modify_font(pango.FontDescription("sans 16"))
+ self.table.attach(self.progress0, 0, 1, 9, 10 )
+
+ # Labels for status update
+ self.correct_count = 0
+ self.correct_counter = gtk.Label(str(self.correct_count))
+ self.correct_counter.modify_font(pango.FontDescription("sans 16"))
+
+ # Ugly code for label color
+ attr = pango.AttrList()
+ fg_color = pango.AttrForeground(0, 65535, 0, 0, 6)
+ attr.insert(fg_color)
+ self.correct_counter.set_attributes(attr)
+
+ #self.table.attach(self.correct_counter, 2, 4, 9, 10 )
+ self.table.attach(self.correct_counter, 3, 5, 9, 10 )
+
+ self.false_count = 0
+ self.false_counter = gtk.Label(str(self.false_count))
+ self.false_counter.modify_font(pango.FontDescription("sans 16"))
+
+ # Ugly code for label color
+ attr = pango.AttrList()
+ fg_color = pango.AttrForeground(0, 0, 65535, 0, 6)
+ attr.insert(fg_color)
+ self.false_counter.set_attributes(attr)
+
+ #self.table.attach(self.false_counter, 2, 4, 10, 11 )
+ self.table.attach(self.false_counter, 3, 5, 10, 11 )
+
+ self.stopwatch_label.show()
+ gobject.timeout_add(1000, self.update_time)
+ self.name_label.show()
+ self.progressbar.show()
+ self.progress0.show()
+ self.correct_counter.show()
+ self.false_counter.show()
+
+
+ self.progress_total = gtk.Label(str(self.total_number_of_calculations))
+ self.progress_total.modify_font(pango.FontDescription("sans 16"))
+ #self.table.attach(self.progress_total, 5, 6, 9, 10 )
+ self.table.attach(self.progress_total, 8, 9, 9, 10 )
+ self.progress_total.show()
+
+ self.sfb_butt = gtk.Button(None, gtk.STOCK_STOP)
+ # self.sfb_butt.connect("clicked", self.display.release_feedb_callback)
+ self.table.attach(self.sfb_butt, 0, 9, 13, 14)
+ self.sfb_alignment = self.sfb_butt.get_children()[0]
+ self.sfb_hbox = self.sfb_alignment.get_children()[0]
+ self.sfb_image, self.sfb_label = self.sfb_hbox.get_children()
+ self.sfb_label.set_label("feedback_table")
+ self.sfb_butt.show() \ No newline at end of file
diff --git a/ReckonPrimer.activity/views/rhs_view_manager.py b/ReckonPrimer.activity/views/rhs_view_manager.py
new file mode 100644
index 0000000..78e6924
--- /dev/null
+++ b/ReckonPrimer.activity/views/rhs_view_manager.py
@@ -0,0 +1,19 @@
+from gtk import Container
+from feedback_view import FeedbackView
+
+
+""" RightHandSide View Manager --- for lack of a better name
+ manages right hand side of display:
+ - SettingsView
+ - FeedbackView
+ - CollectionView
+"""
+class RHSViewManager(Container):
+
+ def __init__(self):
+ __valid_views = ['Settings', 'Feedback', 'Collection']
+ __views = {}
+
+ def show(self, view_name):
+ view = FeedbackView()
+ \ No newline at end of file