def begin_next_word(self): """开始下一个单词 """ self.tested_sum = len(self.passed) + len(self.failed) # 测试过的单词数 #print self.tested_sum # 尚未背完 if self.tested_sum < self.queue_len / 2: self.clear_old_display_now() # 消除上一单词,设置下一单词 else: #判断做错的题目是否为空,如果不是就进行改错 if not self.failed: if self.is_first_time: show_info("答完了!再复习一遍") self.is_first_time = False self.is_correct_mode = False self.passed = [] self.failed = [] self.tested_sum = 0 self.begin_next_word() else: self.finish_test() else: self.is_correct_mode = True show_info("现在把答错的改正一下!") self.how_many_faild = len(self.failed) self.tested_sum = 0 self.test_error_words()
def begin_next_word(self): """开始下一个单词 """ self.tested_sum = len(self.passed) + len(self.failed) # 测试过的单词数 #print self.tested_sum # 尚未背完 if self.tested_sum < self.queue_len/2: self.clear_old_display_now() # 消除上一单词,设置下一单词 else: #判断做错的题目是否为空,如果不是就进行改错 if not self.failed: if self.is_first_time: show_info("答完了!再复习一遍") self.is_first_time = False self.is_correct_mode= False self.passed = [] self.failed = [] self.tested_sum = 0 self.begin_next_word() else: self.finish_test() else: self.is_correct_mode = True show_info("现在把答错的改正一下!") self.how_many_faild = len(self.failed) self.tested_sum = 0 self.test_error_words()
def on_button_create_book(self, widget): """添加按钮的回调事件 """ self.bookname = self.entry_create_name.get_text() message = '' if not self.user_choose_file: message = "请先选择单词列表文件" elif not self.bookname: message = "你必须设置书名" elif os.path.exists( os.path.join(USER_BOOK_PATH, self.bookname + '.book')): message = "此书名的文件已经存在,请换一个" self.bookname = os.path.join(USER_BOOK_PATH, self.bookname + '.book') is_finished = False if message: show_info(message) else: new_book = ProduceBook(self.bookname, self.builder) is_finished = new_book.produce_book(self.user_choose_file) if is_finished: show_info("生成新书成功!新书位于~/.wordjoy/books/目录。")
def finish_test(self): """测试完毕,保存本组单词到记录文件 """ # re = Record() # re.save_reciting_record() show_info("拼写测试完毕!本组词组已经写入记录,等待下次复习") notebook_test = self.builder.get_object("notebook_test") notebook_test.set_current_page(2)
def check_typing_progress(self): """检查当前状态 """ if self.now_turn == self.words_len: self.now_turn = 1 self.now_times += 1 if self.now_times > TYPING_TIMES: show_info("单词拼写记忆完毕!现在进入单词测试!") self.enter_testing_tab() else: show_info("第%d次拼写记忆完毕,进入第%d次拼写记忆" % ((self.now_times -1), self.now_times) ) else: self.now_turn += 1 self.display_now_word()
def test_error_words(self): """测试错误的单词 """ if self.failed: self.clear_old_display_now() # 消除上一单词,设置下一单词 else: if self.is_first_time: self.is_correct_mode = False self.is_first_time = False self.passed = [] self.failed = [] show_info("加油!再复习一遍") self.clear_old_display_now() # 消除上一单词,设置下一单词 else: self.finish_test()
def check_typing_progress(self): """检查当前状态 """ if self.now_turn == self.words_len: self.now_turn = 1 self.now_times += 1 if self.now_times > TYPING_TIMES: show_info("单词拼写记忆完毕!现在进入单词测试!") self.enter_testing_tab() else: show_info("第%d次拼写记忆完毕,进入第%d次拼写记忆" % ((self.now_times - 1), self.now_times)) else: self.now_turn += 1 self.display_now_word()
def change_to_recite_tab(self): """功能: 1、跳转到“单词初记” 2、开始开始”单词初记“ """ self.object_list = [] recite_tabs = self.builder.get_object("notebook_recite") sidebar_notebook = self.builder.get_object("sidebar_notebook") # 当前选中 if self.select_count >= 5: #print self.dir_file sidebar_notebook.set_current_page(2) # 自动跳转到页面“单词初记”去 recite_tabs.set_current_page(0) # 自动跳转到页面“单词初记”去 self.singleton = Recite.new() print "the id is:", id(self.singleton) self.singleton.run(self.builder) # 调用单词初记功能 else: show_info("单词数少于5个,不能进行背诵!")
def on_button_create_book(self, widget): """添加按钮的回调事件 """ self.bookname = self.entry_create_name.get_text() message = '' if not self.user_choose_file: message = "请先选择单词列表文件" elif not self.bookname: message = "你必须设置书名" elif os.path.exists(os.path.join(USER_BOOK_PATH, self.bookname + '.book')): message = "此书名的文件已经存在,请换一个" self.bookname = os.path.join(USER_BOOK_PATH, self.bookname + '.book') is_finished = False if message: show_info(message) else: new_book = ProduceBook(self.bookname, self.builder) is_finished = new_book.produce_book(self.user_choose_file) if is_finished: show_info("生成新书成功!新书位于~/.wordjoy/books/目录。")