diff options
author | Assim <assim@localhost.localdomain> | 2008-07-27 21:34:19 (GMT) |
---|---|---|
committer | Assim <assim@localhost.localdomain> | 2008-07-27 21:34:19 (GMT) |
commit | 09bf218f51a3586a34ec6a3a25b23ec1d00f18da (patch) | |
tree | 4220f5c1d3efa1c5f12d6423706f7a28f1253445 /las-gui.py | |
parent | 421881b00310f3aa540be1a700e38a3921a13fbd (diff) |
phoneme support + bug fixes + GUI modified
Diffstat (limited to 'las-gui.py')
-rwxr-xr-x | las-gui.py | 62 |
1 files changed, 33 insertions, 29 deletions
@@ -1,6 +1,5 @@ #!/usr/bin/env python -# example helloworld.py import pygtk pygtk.require('2.0') @@ -12,10 +11,11 @@ class LS_gui: # This is a callback function. The data arguments are ignored # in this example. More on callbacks below. def __init__(self, handle): - self.__init__ + self.__init__() def __init__(self): DBname = "dict.db" + self.use_phoneme = False self.las = Listenspell(DBname) self.load_activity_interface() self.play_game("start") @@ -24,7 +24,7 @@ class LS_gui: def destroy(self, widget, data=None): #print "destroy signal occurred" - gtk.main_quit() + self.game_exit() def load_activity_interface(self): self.main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) @@ -59,15 +59,15 @@ class LS_gui: #self.label_v_left_a.show() #self.label_v_left_b.show() - self.main_output_view = gtk.TextView() - self.main_output_buffer = gtk.TextBuffer() + #self.main_output_view = gtk.TextView() + #self.main_output_buffer = gtk.TextBuffer() #self.main_output_buffer.set_text("This is main output") - self.main_output_view.set_editable(False) - self.main_output_view.set_buffer(self.main_output_buffer) + #self.main_output_view.set_editable(False) + #self.main_output_view.set_buffer(self.main_output_buffer) - self.display_main_output("This is main output") + #self.display_main_output("This is main output") - self.main_output_view.show_all() + #self.main_output_view.show_all() self.text_input = gtk.Entry() #self.text_input.set_text("Preset input text") @@ -95,7 +95,7 @@ class LS_gui: self.text_submit_button.connect("clicked", self.submit_button_clicked, None) self.console_text_buffer = gtk.TextBuffer() - self.console_text_buffer.set_text("This is hint text") + #self.console_text_buffer.set_text("This is hint text") self.console_text_view.set_editable(False) self.console_text_view.set_buffer(self.console_text_buffer) @@ -103,12 +103,12 @@ class LS_gui: self.console_text_frame.add(self.console_text_sw) self.console_text_frame.show_all() - self.vcontainer_left.pack_start(self.main_output_view, True, True ) + #self.vcontainer_left.pack_start(self.main_output_view, True, True ) #self.vcontainer_left.pack_start(self.label_v_left_b, True, False ) + + self.vcontainer_left.pack_start(self.console_text_frame, True, True ) self.vcontainer_left.pack_start(self.text_input, False, True ) self.vcontainer_left.pack_start(self.text_submit_button, False, False ) - self.vcontainer_left.pack_start(self.console_text_frame, True, True ) - ################################################True################ @@ -209,7 +209,10 @@ class LS_gui: return False def repeat_word_button_clicked(self, widget, data = None): - self.las.say_text(self.elem) + if self.elem != self.pronounelem and self.use_phoneme: + self.las.say_text(self.pronounelem, is_phoneme = True) + else: + self.las.say_text(self.elem) def get_def_button_clicked(self, widget, data = None): def_list = self.las.get_word_info(self.wordid, "def") @@ -268,7 +271,7 @@ class LS_gui: elif response == gtk.RESPONSE_NONE: self.game_exit() - def local_skill_level_focus(self, widget, event, data= None): + def local_skill_level_focus(self, widget, event, data= None): # not in use #print "text_input_focus_in" return False @@ -282,6 +285,7 @@ class LS_gui: self.las.say_text(char) self.las.say_text(string) + ################################################################ #####################Update methods############################# @@ -323,20 +327,19 @@ class LS_gui: self.pronounelem = self.las.get_word_info(self.wordid, "phnm") #get a pronounciation from the list self.display_console("Spell...") # say the explanation if the word is ambiguous. - if self.elem != self.pronounelem: # determine whether to bother pronouncing a description - - self.las.say_text("Spell... ... " + self.elem + "... " + self.pronounelem) + if self.elem != self.pronounelem and self.use_phoneme: # determine whether to bother pronouncing a description + self.las.say_text("Spell..." + self.pronounelem, is_phoneme = True) else: #print "Spell... " - self.las.say_text("Spell... ... " + self.elem) + self.las.say_text("Spell..." + self.elem) def play_game(self,mode = "start"): if mode == "start": self.las.play_sound("begin") self.this_level_size = 7 self.this_level_max_error = 3 - self.display_main_output("Welcome") - self.las.say_text("Welcome") + #self.display_main_output("Welcome") + self.las.say_text("Welcome", wait = False) self.ask_skill_level() self.wordid_list = self.las.load_wordid(self.this_level_size + self.this_level_max_error) self.this_level_num_words = len(self.wordid_list) @@ -367,19 +370,20 @@ class LS_gui: data = "\n" + data self.console_text_buffer.insert_at_cursor(data) - def display_main_output(self, data, newline = True, clear_previous = True): - if clear_previous == True: - self.main_output_buffer.set_text(data) - elif newline == True: - text = "\n" + data - self.main_output_buffer.insert_at_cursor(data) - else: - self.main_output_buffer.insert_at_cursor(data) + #def display_main_output(self, data, newline = True, clear_previous = True): + #if clear_previous == True: + #self.main_output_buffer.set_text(data) + #elif newline == True: + #text = "\n" + data + #self.main_output_buffer.insert_at_cursor(data) + #else: + #self.main_output_buffer.insert_at_cursor(data) ################################################################ def game_exit(self): + self.las.exit_game() gtk.main_quit() ########################Game Logic############################## |