diff options
author | Mike Major <jmikem@bellsouth.net> | 2009-08-29 12:35:02 (GMT) |
---|---|---|
committer | Mike Major <jmikem@bellsouth.net> | 2009-08-29 12:35:02 (GMT) |
commit | 83e8e566fbc8f9e9ed5b13e632951a523ce9fec9 (patch) | |
tree | 639f933f8dbc31ffe6cba7ab7803a6d854ae7bd3 | |
parent | 9456b125831c9cbc06f340e269c261d9627ac083 (diff) |
Added timer to change the user outputs. Started with tabs for the introduction to rounding.
-rw-r--r-- | data.py | 2 | ||||
-rw-r--r-- | hoparound.py | 5 | ||||
-rw-r--r-- | view.py | 45 |
3 files changed, 36 insertions, 16 deletions
@@ -72,7 +72,7 @@ class LevelData(): self.mult.append(int(math.floor(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
self.mult.append(int(math.ceil(self.random_number/(self.answer_decade*factor)) * self.answer_decade * factor))
- def show_game_data(self):
+ def get_game_data(self):
temp = "\nLevel: " + str(self.current_level)
#temp += "\nRandom Number: " + str(self.random_number)
#temp += "\nDecade: " + str(self.answer_decade)
diff --git a/hoparound.py b/hoparound.py index 9d98c5e..a267452 100644 --- a/hoparound.py +++ b/hoparound.py @@ -1,6 +1,6 @@ from data import LevelData
from view import Views
-import gtk, locale
+import gtk, locale, gobject
from sugar.activity import activity import locale @@ -43,8 +43,9 @@ class HopaRoundActivity(activity.Activity): self.ui.answer_nan()
else:
if self.data.check_answer(num):
- self.ui.answer_correct(self.data)
+ self.ui.answer_correct(self.data) else:
self.ui.answer_incorrect(self.data)
+ gobject.timeout_add(2000, self.ui.clear, self.data) self.setup(self.data, self.ui)
@@ -4,9 +4,11 @@ import locale class Views(): def __init__(self): locale.setlocale(locale.LC_ALL,"") - self.user_interaction = gtk.HBox() + self.user_interaction = gtk.Notebook() + self.quiz_tab = gtk.HBox() + self.user_interaction.append_page(self.quiz_tab) self.user_input = gtk.VBox() - self.user_interaction.pack_start(self.user_input, False, False, 10) + self.quiz_tab.pack_start(self.user_input, False, False, 10) self.rounding_phrase = gtk.Label("rounding phrase") self.user_input.pack_start(self.rounding_phrase, False, False, 10) #create the notebook @@ -15,7 +17,8 @@ class Views(): self.user_input.pack_start(self.tabber, False, False, 10) #create the slider tab self.slider_tab = gtk.VButtonBox() - self.slider_instruction = gtk.Label("Move the slider to choose the correct answer") + self.slider_instruction = gtk.Label() + self.slider_instruction.set_markup("<big>Move the slider to choose the correct answer</big>") self.slider_tab.pack_start(self.slider_instruction, False, False, 10) self.slider_adjustment = gtk.Adjustment() self.slider_tool = gtk.HScale(self.slider_adjustment) @@ -26,7 +29,8 @@ class Views(): self.tabber.append_page(self.slider_tab) #create the multiple choice tab self.mult_tab = gtk.VBox() - self.mult_instruction = gtk.Label("Choose one of the answers below") + self.mult_instruction = gtk.Label() + self.mult_instruction.set_markup("<big>Choose one of the answers below</big>") self.mult_tab.pack_start(self.mult_instruction, False, False, 10) self.mult_1 = gtk.Button() self.mult_tab.pack_start(self.mult_1, False, False, 10) @@ -39,7 +43,8 @@ class Views(): self.tabber.append_page(self.mult_tab) #create the entry tab self.entry_tab = gtk.VButtonBox() - self.entry_instruction = gtk.Label("Type your answer below and click 'OK'") + self.entry_instruction = gtk.Label() + self.entry_instruction.set_markup("<big>Type your answer below and click 'OK'</big>") self.entry_tab.pack_start(self.entry_instruction, False, False, 10) self.entry_tool = gtk.Entry() self.entry_tab.pack_start(self.entry_tool, False, False, 10) @@ -48,7 +53,7 @@ class Views(): self.tabber.append_page(self.entry_tab) #create the output self.user_output = gtk.VBox() - self.user_interaction.pack_start(self.user_output, False, False, 10) + self.quiz_tab.pack_start(self.user_output, False, False, 10) self.output = gtk.Label("") self.output.set_alignment(0.1, 0.5) self.user_output.pack_start(self.output, False, False, 10) @@ -56,15 +61,23 @@ class Views(): self.user_output.pack_start(self.image_output, False, False, 10) self.image_correct_answer = gtk.gdk.pixbuf_new_from_file("hoppy-right.svg") self.image_incorrect_answer = gtk.gdk.pixbuf_new_from_file("hoppy-wrong.svg") + # intro tab + self.intro_tab = gtk.VBox() + self.intro_text = gtk.Label() + self.intro_text.set_markup("<big>Let's round numbers with Hoppy the Grasshopper</big>") + self.intro_tab.pack_start(self.intro_text, False, False, 10) + self.introduction = gtk.Notebook() + self.intro_tab.pack_start(self.introduction, False, False, 10) + self.user_interaction.append_page(self.intro_tab) def get_user_interaction(self): return self.user_interaction def set_rounding_phrase(self, data): - text = "Round the number <b>" + text = "<big>Round the number <b>" text += self.locl(data.random_number) text += "</b> to the nearest <b>" - text += self.locl(data.answer_decade) + "</b>" + text += self.locl(data.answer_decade) + "</b></big>" self.rounding_phrase.set_markup(text) def set_choices(self, number, choices): @@ -78,27 +91,33 @@ class Views(): self.entry_tool.set_text("") def answer_correct(self, data): - text = "<span foreground=\"dark green\"><b>That's Right!!! =8-) </b></span> \n\n" + text = "<big><span foreground=\"dark green\"><b>That's Right!!! =8-) </b></span> \n\n" text += self.locl(data.random_number) + " rounded to the nearest " text += self.locl(data.answer_decade) + " is " + self.locl(data.correct_answer) if data.level_change: text += "\n\n<span foreground=\"dark green\"><b>You made it to the next level! =8^P</b></span>" - text += "\n" #+ data.show_game_data() + text += "</big>" self.output.set_markup(text) self.image_output.set_from_pixbuf(self.image_correct_answer) def answer_incorrect(self, data): - text = "<span foreground=\"red\"><b>Sorry Charlie >:( </b></span> \n\n" + text = "<big><span foreground=\"red\"><b>Sorry Charlie >:( </b></span> \n\n" text += self.locl(data.random_number) + " rounded to the nearest " text += self.locl(data.answer_decade) + " is " + self.locl(data.correct_answer) if data.level_change: text += "\n\n<span foreground=\"red\"><b>You dropped a level. Concentrate! >8^|</b></span>" - text += "\n" #+ data.show_game_data() + text += "</big>" self.output.set_markup(text) self.image_output.set_from_pixbuf(self.image_incorrect_answer) + self.output.queue_draw() + + def clear(self, data): + self.output.set_markup(data.get_game_data()) + self.image_output.clear() + return False def answer_nan(self): - text = "<span foreground=\"blue\"><b>Please enter only numbers.</b></span> \n\n" + text = "<big><span foreground=\"blue\"><b>Please enter only numbers.</b></span> \n\n</big>" self.output.set_markup(text) def set_tab(self, data): |