탭으로 작업하고 애플리케이션에서 워크플로를 분리하기 위해 Tkinter는 노트북을 제공합니다. 위젯. 노트북을 사용할 수 있습니다. 위젯을 사용하여 애플리케이션에서 탭을 생성합니다. 탭은 특정 프레임이나 이벤트를 다른 프레임이나 이벤트와 분리하는 데 유용합니다.
일반적으로 노트북 위젯은 ttk 를 사용하여 구성하고 스타일을 지정할 수 있습니다. 테마 위젯. 따라서 Notebook 위젯의 스타일을 지정하기 위해 TNotebook을 전달합니다. 및 T노트북 . 탭 구성의 매개변수. 특정 탭을 클릭하면 제거할 수 있는 직사각형 파선이 나타날 수 있습니다.
예시
# Import the required library
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame
win = Tk()
win.geometry("700x350")
# Create an instance of ttk
style = ttk.Style()
# Define Style for Notebook widget
style.layout("Tab", [('Notebook.tab', {'sticky': 'nswe', 'children':
[('Notebook.padding', {'side': 'top', 'sticky': 'nswe', 'children':
[('Notebook.label', {'side': 'top', 'sticky': ''})],
})],
})]
)
# Use the Defined Style to remove the dashed line from Tabs
style.configure("Tab", focuscolor=style.configure(".")["background"])
# Create a Notebook widget
my_notebook= ttk.Notebook(win)
my_notebook.pack(expand=1,fill=BOTH)
# Creating Tabs
tab1 = ttk.Frame(my_notebook)
my_notebook.add(tab1, text= "Tab 1")
tab2 = ttk.Frame(my_notebook)
my_notebook.add(tab2, text= "Tab2")
# Create a Label in Tabs
Label(tab1, text= "Hello, Howdy?",
font = ('Helvetica 20 bold')).pack()
Label(tab2, text= "This is a New Tab Context",
font = ('Helvetica 20 bold')).pack()
win.mainloop() 출력
위의 코드를 실행하면 여러 탭이 포함된 창이 표시됩니다.

창에서 탭을 전환하면 내용이 표시됩니다.
