使用tkinter.ttk模块的Notebook创建一个选项卡式窗口。
首先创建notbook,然后在其上添加frame。
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
root.title("hello tk")
tab_container = ttk.Notebook(root)
tab_container.pack(fill='both', expand=1)
frame1 = tk.Frame(tab_container)
tab_container.add(frame1, text="test1")
frame2 = tk.Frame(tab_container)
tab_container.add(frame2, text="test2")
root.mainloop()