diff options
Diffstat (limited to 'view.py')
-rw-r--r-- | view.py | 59 |
1 files changed, 44 insertions, 15 deletions
@@ -5,17 +5,45 @@ class Views(): def __init__(self): locale.setlocale(locale.LC_ALL,"") self.user_interaction = gtk.Notebook() + self.user_interaction.set_show_tabs(False) + # + # create the intro tab + self.intro_tab = gtk.VBox() + self.user_interaction.append_page(self.intro_tab) + # intro - heading + self.intro_heading = gtk.Label() + self.intro_heading.set_markup("<big>Let's round numbers with Hoppy the Grasshopper</big>") + self.intro_tab.pack_start(self.intro_heading, False, False, 10) + # intro - intro area + self.intro_area = gtk.HBox() + self.intro_tab.pack_start(self.intro_area, False, False, 10) + # intro - image + self.image_intro = gtk.Image() + self.intro_area.pack_start(self.image_intro, False, False, 10) + self.image_intro.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file("hoppy-title.svg")) + # intro - play button + self.play = gtk.Button("Play") + self.intro_tab.pack_start(self.play, False, False, 10) + self.play.connect("clicked", self.play_clicked) + # intro - text tabs + self.introduction = gtk.Notebook() + self.introduction.set_show_tabs(False) + self.intro_area.pack_start(self.introduction, False, False, 10) + self.intro_tab1 = gtk.Label("intro text") + self.introduction.append_page(self.intro_tab1) + # + # create the quiz tab self.quiz_tab = gtk.HBox() self.user_interaction.append_page(self.quiz_tab) self.user_input = gtk.VBox() 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 + # quiz - create the play notebook to show the widgets for playing self.tabber = gtk.Notebook() self.tabber.set_show_tabs(False) self.user_input.pack_start(self.tabber, False, False, 10) - #create the slider tab + # quiz - create the slider tab self.slider_tab = gtk.VButtonBox() self.slider_instruction = gtk.Label() self.slider_instruction.set_markup("<big>Move the slider to choose the correct answer</big>") @@ -27,7 +55,7 @@ class Views(): self.slider_click = gtk.Button("OK") self.slider_tab.pack_start(self.slider_click, False, False, 10) self.tabber.append_page(self.slider_tab) - #create the multiple choice tab + # quiz - create the multiple choice tab self.mult_tab = gtk.VBox() self.mult_instruction = gtk.Label() self.mult_instruction.set_markup("<big>Choose one of the answers below</big>") @@ -41,7 +69,7 @@ class Views(): self.mult_4 = gtk.Button() self.mult_tab.pack_start(self.mult_4, False, False, 10) self.tabber.append_page(self.mult_tab) - #create the entry tab + # quiz - create the entry tab self.entry_tab = gtk.VButtonBox() self.entry_instruction = gtk.Label() self.entry_instruction.set_markup("<big>Type your answer below and click 'OK'</big>") @@ -51,7 +79,7 @@ class Views(): self.entry_click = gtk.Button("OK") self.entry_tab.pack_start(self.entry_click, False, False, 10) self.tabber.append_page(self.entry_tab) - #create the output + # quiz - create the output self.user_output = gtk.VBox() self.quiz_tab.pack_start(self.user_output, False, False, 10) self.output = gtk.Label("") @@ -61,14 +89,10 @@ 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) + # quiz - help + self.help = gtk.Button("Help") + self.help.connect("clicked", self.help_clicked) + self.user_input.pack_start(self.help, False, False, 10) def get_user_interaction(self): return self.user_interaction @@ -109,10 +133,9 @@ class Views(): 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.output.set_markup("<big>" + data.get_game_data() + "</big>") self.image_output.clear() return False @@ -129,6 +152,12 @@ class Views(): elif data.question_count > data.thresh_slider: self.tabber.set_current_page(0) self.slider_tool.grab_focus() + + def play_clicked(self, widget): + self.user_interaction.set_current_page(1) + + def help_clicked(self, widget): + self.user_interaction.set_current_page(0) def locl(self, characters): return str(locale.format("%d", characters, True)) |