예제 #1
0
    def __init__(self):
        self.timer_id = 0
        self.trainer = Quiz_Trainer()
        # gconf #
        self.gconf_watcher = Gconf_Prefs()
        quiz_file_path = self.gconf_watcher.gconf_client.get_string(
            self.gconf_watcher.DEFAULT_QUIZ_KEY)
        # widgets #
        xml = gtk.glade.XML(self.GLADE_FILE, "main_window", APP)
        gw = xml.get_widget
        self.main_window = gw("main_window")
        self.edit_menuitem = gw("edit_menuitem")
        self.main_notbook_tabs = {
            "multi": [gw("multi_tab_label"),
                      gw("multi_tab_vbox")],
            "simple": [gw("simple_tab_label"),
                       gw("simple_tab_vbox")],
            "flash": [gw("flash_tab_label"),
                      gw("flash_tab_vbox")]
        }
        self.subquiz_combobox = gw("subquiz_combobox")
        self.word_treeview = gw("word_treeview")
        self.multi_answer_vbuttonbox = gw("multi_answer_vbuttonbox")
        self.simple_answer_entry = gw("simple_answer_entry")
        self.question_topic_labels = [
            gw("multi_question_topic_label"),
            gw("simple_question_topic_label"),
            gw("flash_question_topic_label")
        ]
        self.question_labels = [
            gw("multi_question_label"),
            gw("simple_question_label"),
            gw("flash_question_label")
        ]
        self.multi_question_buttons = [
            gw("mq_button0"),
            gw("mq_button1"),
            gw("mq_button2"),
            gw("mq_button3"),
            gw("mq_button4"),
            gw("mq_button5"),
            gw("mq_button6")
        ]
        self.simple_question_button = gw("simple_question_button")
        self.flash_notebook = gw("flash_notebook")
        self.flash_answer_buttons = [
            gw("flash_answer_button_no"),
            gw("flash_answer_button_yes")
        ]
        self.flash_answer_label = gw("flash_answer_label")
        self.progressbar1 = gw("progressbar1")
        sb = self.statusbar1 = gw("statusbar1")
        self.statusbar_contextid = {
            "last_answer":
            sb.get_context_id("The answer to the last asked question.")
        }
        #
        try:
            self.trainer.load_quiz(quiz_file_path)
        except IOError:
            quiz_file_path = resource_filename(__name__,
                                               '../quizzes/deu-fra.drill')
            self.trainer.load_quiz(quiz_file_path)

        # connect signals #
        xml.signal_autoconnect(self)
        self.trainer.connect('quiz_changed', self.on_quiz_switch)
        self.trainer.connect('question_changed', self.update_gui)
        self.trainer.connect('break_time', self.end_testing_interval)
        self.trainer.connect('direction_changed',
                             self.on_question_direction_changed)
        #
        self.on_quiz_switch()