def event4(): global text text = button4['text'] context = chapter(book_info.get(text), title) read_context(window, result=result, chapter_name=text, cache=context, sc=sc, mc=mc) for c in dc.keys(): c.destroy()
def prev(): """ 上一章 """ global context_name index, length = get_index() if index == 0: tkinter.messagebox.showwarning(title='提示', message='当前为第一章!') return context_name = chapters[index - 1] chap_text.set(context_name) url = book_info.get(context_name) text = chapter(url, title) show_context(t1, text)
def last(): """ 打开最后一章 """ cha = chapter(chapter_info.get(new_cha), title) read_context(window, result=result, chapter_name=new_cha, cache=cha, sc=search_controls, mc=mid_controls) for c in mid_controls.keys(): c.destroy() for c in search_controls.keys(): c.place_forget()
def next(): """ 下一章 """ global context_name index, length = get_index() # 判断是否为最后一章 if index == length - 1: tkinter.messagebox.showwarning(title='提示', message='当前为最新章节!') return # 获取下一章的章节名 context_name = chapters[index + 1] # 设置显示的章节名 chap_text.set(context_name) # 获取本章的链接 url = book_info.get(context_name) # 获取正文内容 text = chapter(url, title) # 展示正文内容 show_context(t1, text)
def jump(): """ 跳转 """ global context_name # 获取输入的内容 num = number.get() # 判断输入的内容是否符合要求 try: num = int(num) num = abs(num) except: tkinter.messagebox.showwarning(title='提示', message='请填写数字!') return # 判断是否超出最大章节数 if num > len(chapters) - 1: num = len(chapters) - 1 tkinter.messagebox.showwarning(title='提示', message='数值过大,即将转到最新章节!') context_name = chapters[num] chap_text.set(context_name) url = book_info.get(context_name) text = chapter(url, title) number.set('') show_context(t1, text)