diff options
author | Roberto Cristaldo <rcristal@gmail.com> | 2013-01-29 02:12:12 (GMT) |
---|---|---|
committer | Roberto Cristaldo <rcristal@gmail.com> | 2013-01-29 02:12:12 (GMT) |
commit | b2ca03b218aa5faf0d70e503b83f348fa55ed9ab (patch) | |
tree | 54459b07ee0bdeddf634a5189521ea5a62b501a8 | |
parent | 25fa63fc55f08f122928eefe42928fa0e21b93f1 (diff) |
Casi casi... solo falta el ciclo y la parte grafica
-rw-r--r-- | activity.py | 63 | ||||
-rwxr-xr-x | elephant.py | 10 |
2 files changed, 47 insertions, 26 deletions
diff --git a/activity.py b/activity.py index 5a86c25..ca68e50 100644 --- a/activity.py +++ b/activity.py @@ -128,27 +128,42 @@ class ElephantActivity(activity.Activity): hbox_03.add(button_option3) # Connections - button_repeat.connect('clicked', self.__button_clicked, \ - word, \ - choice_letter.letter, \ + button_repeat.connect('clicked', self.__button_clicked_rep, \ + word, \ + choice_letter.letter, \ choice_letter.place_word) - label_word.connect('focus', self.__label_focus, \ - word, \ - choice_letter.letter, \ + label_word.connect('focus', self.__label_focus_lw, \ + word, \ + choice_letter.letter, \ choice_letter.place_word) options_places = choice_letter.random_places - label = self.set_opton_label('Opcion 1:', options_places[0]) + op_label = choice_letter.translate_to_str(options_places[0]) + label = self.set_option_label('Opcion 1:', op_label) button_option1.set_label(label) - label = self.set_opton_label('Opcion 2:', options_places[1]) + op_label = choice_letter.translate_to_str(options_places[1]) + label = self.set_option_label('Opcion 2:', op_label) button_option2.set_label(label) - label = self.set_opton_label('Opcion 3:', options_places[2]) + op_label = choice_letter.translate_to_str(options_places[2]) + label = self.set_option_label('Opcion 3:', op_label) button_option3.set_label(label) - + button_option1.connect('clicked', self.__button_clicked_op, \ + choice_letter.letter_index, \ + options_places[0]) + + button_option2.connect('clicked', self.__button_clicked_op, \ + choice_letter.letter_index, \ + options_places[1]) + + button_option3.connect('clicked', self.__button_clicked_op, \ + choice_letter.letter_index, \ + options_places[2]) + + # ShowMeTheMoney!!! vbox_main.show_all() #label_word.is_focus = true @@ -178,7 +193,7 @@ class ElephantActivity(activity.Activity): return label # Create proper lables for options buttons - def set_opton_label(self, option, position): + def set_option_label(self, option, position): label = option label += ' Es la ' label += position @@ -187,23 +202,29 @@ class ElephantActivity(activity.Activity): return label # Say the word and riddle on button click - def __button_clicked(self, button, \ - word, \ - letter_to_say, \ + def __button_clicked_rep(self, button, \ + word, \ + letter_to_say, \ place_word): - self.speech_to_say(word, \ - letter_to_say, \ + self.speech_to_say(word, \ + letter_to_say, \ place_word) + def __button_clicked_op(self, button, true_letter, press_letter): + if true_letter == press_letter: + self.say('Okey') + else: + self.say('Error') + # Say the word and riddle on label focus - def __label_focus(self, label, \ - word, \ - letter_to_say, \ + def __label_focus_lw(self, label, \ + word, \ + letter_to_say, \ place_word): - self.speech_to_say(word, \ - letter_to_say, \ + self.speech_to_say(word, \ + letter_to_say, \ place_word) # Say the word and riddle diff --git a/elephant.py b/elephant.py index 8254908..77b1951 100755 --- a/elephant.py +++ b/elephant.py @@ -64,7 +64,7 @@ class letters: self.relative_place = self._get_relative_place(self.letter_index, \ self.all_indexes) - self.place_word = self._translate_to_str(self.relative_place) + self.place_word = self.translate_to_str(self.relative_place) self.random_places = self._get_random_places(self.letter_index, \ self.false_options) @@ -126,7 +126,7 @@ class letters: # Translate relative place to words - def _translate_to_str(self, relative_place): + def translate_to_str(self, relative_place): if relative_place == 999: return False @@ -148,9 +148,9 @@ class letters: def _get_random_places(self, true_choice, false_choice): options = [] - options.append(self._translate_to_str(true_choice)) - options.append(self._translate_to_str(false_choice[0])) - options.append(self._translate_to_str(false_choice[1])) + options.append(true_choice) + options.append(false_choice[0]) + options.append(false_choice[1]) random.shuffle(options) |