import tkinter as tk from tkinter import ttk def show(): name = name_va.get() print('输入的名字是:', name) def download(): name = num_va.get() print('输入的序号:', name) root = tk.Tk() root.title('小说下载器') root.geometry('500x500+200+200') name_va = tk.StringVar() search_frame = tk.Frame(root) search_frame.pack(pady=10) tk.Label(search_frame, text='书名 作者', font=('微软雅黑', 15)).pack(side=tk.LEFT, padx=10) tk.Entry(search_frame, relief='flat', textvariable=name_va).pack(side=tk.LEFT) num_va = tk.StringVar() download_frame = tk.Frame(root) download_frame.pack(pady=10) tk.Label(download_frame, text='小说 序号', font=('微软雅黑', 15)).pack(side=tk.LEFT, padx=10) tk.Entry(download_frame, relief='flat', textvariable=num_va).pack(side=tk.LEFT) button_frame = tk.Frame(root) button_frame.pack(pady=10) tk.Button(button_frame, text='查询', font=('微软雅黑', 10), relief='flat', bg='#88e2d6', width=10, command=show).pack(side=tk.LEFT, padx=10) tk.Button(button_frame, text='下载', font=('微软雅黑', 10), relief='flat', bg='#88e2d6', width=10, command=download).pack(side=tk.LEFT, padx=10) columns = ('num', 'writer', 'name', 'novel_id') columns_value = ('序号', '作者', '书名', '书ID') tree_view = ttk.Treeview(root, height=18, show='headings', columns=columns) tree_view.column('num', width=40, anchor='center') tree_view.column('writer', width=40, anchor='center') tree_view.column('name', width=40, anchor='center') tree_view.column('novel_id', width=40, anchor='center') tree_view.heading('num', text='序号') tree_view.heading('writer', text='作者') tree_view.heading('name', text='书名') tree_view.heading('novel_id', text='书ID') tree_view.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) root.mainloop()