有没有办法将笔记本的标签设置在另一个下面?

tSs*_*tSs 3 python user-interface tabs tkinter ttk

到目前为止,在使用ttk.Notebook小部件时,但我无法将标签设置在彼此下方,它们不断向东堆积。

有没有办法将它们设置为以某种方式堆叠?

tag*_*aga 6

是的,请检查此代码:

import tkinter as tk
from tkinter import ttk

root = tk.Tk()

style = ttk.Style(root)
style.configure('lefttab.TNotebook', tabposition='wn')

notebook = ttk.Notebook(root, style='lefttab.TNotebook')

f1 = tk.Frame(notebook, bg='red', width=200, height=200)
f2 = tk.Frame(notebook, bg='blue', width=200, height=200)

notebook.add(f1, text='Frame 1')
notebook.add(f2, text='Frame 2')

notebook.grid(row=0, column=0, sticky="nw")

root.mainloop()
Run Code Online (Sandbox Code Playgroud)