프레임 Tkinter의 위젯은 위젯과 기타 모든 GUI 구성 요소를 배치할 수 있는 컨테이너처럼 작동합니다. 프레임 너비를 동적으로 변경하려면 configure() 메서드를 사용하고 width 속성입니다.
예시
이 예에서는 기본 창 안에 채워진 버튼을 만들었으며 버튼을 클릭할 때마다 프레임의 너비가 업데이트됩니다.
# 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("700x350")
def update_width():
frame.config(width=100)
# Create a frame
frame=Frame(win, bg="skyblue3", width=700, height=250)
frame.pack()
# Add a button in the main window
ttk.Button(win, text="Update", command=update_width).pack()
win.mainloop() 출력
위의 코드를 실행하여 프레임 위젯과 버튼이 포함된 창을 표시합니다.

프레임 너비를 업데이트하려면 "업데이트" 버튼을 클릭하십시오.
