# -*- coding: utf-8 -*-
"""
将耗时间的任务放到线程中以获得更好的用户体验。
"""
import time
import tkinter
import tkinter.messagebox


def download():
    # 模拟下载任务需要花费10秒时间
    time.sleep(10)
    tkinter.messagebox.showinfo('提示', '下载完成')


def show_about():
    tkinter.messagebox.showinfo('关于', '作者：罗浩')


def main():
    top = tkinter.Tk()
    top.title('单线程')
    top.geometry('200x150')
    top.wm_attributes('-topmost', True)

    panel = tkinter.Frame(top)
    button1 = tkinter.Button(panel, text='下载', command=download)
    button1.pack(side='left')
    button2 = tkinter.Button(panel, text='关于', command=show_about)
    button2.pack(side='right')
    panel.pack(side='bottom')

    tkinter.mainloop()


if __name__ == '__main__':
    main()

[((12, 4, 12, 18), 'time.sleep', 'time.sleep', ({(12, 15, 12, 17): '(10)'}, {}), '(10)', False, 'import time\n'), ((13, 4, 13, 57), 'tkinter.messagebox.showinfo', 'tkinter.messagebox.showinfo', ({(13, 32, 13, 40): '"""提示"""', (13, 42, 13, 56): '"""下载完成"""'}, {}), "('提示', '下载完成')", False, 'import tkinter\n'), ((17, 4, 17, 60), 'tkinter.messagebox.showinfo', 'tkinter.messagebox.showinfo', ({(17, 32, 17, 40): '"""关于"""', (17, 42, 17, 59): '"""作者：罗浩"""'}, {}), "('关于', '作者：罗浩')", False, 'import tkinter\n'), ((21, 10, 21, 22), 'tkinter.Tk', 'tkinter.Tk', ({}, {}), '()', False, 'import tkinter\n'), ((26, 12, 26, 30), 'tkinter.Frame', 'tkinter.Frame', ({(26, 26, 26, 29): 'top'}, {}), '(top)', False, 'import tkinter\n'), ((27, 14, 27, 68), 'tkinter.Button', 'tkinter.Button', (), '', False, 'import tkinter\n'), ((29, 14, 29, 70), 'tkinter.Button', 'tkinter.Button', (), '', False, 'import tkinter\n'), ((33, 4, 33, 22), 'tkinter.mainloop', 'tkinter.mainloop', ({}, {}), '()', False, 'import tkinter\n')]