Tkinter Frame 위젯은 프레임에 여러 위젯을 그룹화하는 데 매우 유용합니다. 여기에는 부모 창에 적용되는 모든 기능과 속성이 포함됩니다.
Frame 위젯을 생성하기 위해 Frame 클래스의 객체를 인스턴스화할 수 있습니다. 창에서 프레임 위젯을 정의하면 위젯을 직접 선택하여 프레임에 배치할 수 있습니다.
예시
이 예에서는 Frame 위젯을 만들고 그 안에 몇 가지 위젯을 정의했습니다.
# Import the required libraries
from tkinter import *
from tkinter import ttk
# Create an instance of tkinter frame or window
win=Tk()
# Set the size of the window
win.geometry("700x250")
def on_click():
label["text"]="Hello "+ str(entry.get())
# Create a Frame widget
frame=Frame(win, width=400, height=300)
# Add a label in the frame widget
label=Label(frame, text="Enter your name", font=('Calibri 13'))
label.pack(pady=10)
# Add an Entry widget
entry=Entry(frame, width=25)
entry.pack()
# Create a button
ttk.Button(frame, text="Click Me", command=on_click).pack()
frame.pack()
win.mainloop() 출력
위의 코드를 실행하면 Entry 위젯, 레이블 위젯 및 프레임의 버튼이 포함된 창이 표시됩니다.

주어진 텍스트 필드에 이름을 입력하고 버튼을 클릭하면 화면에 메시지가 표시됩니다.
