Tkinter 창 프레임 크기를 고정하는 방법

Jinku Hu 2023년1월30일
  1. 프레임 크기 조정 가능 방법
  2. minsizemaxsize 프레임
Tkinter 창 프레임 크기를 고정하는 방법

일부 시나리오에서는 Tkinter 창 프레임 크기를 고정 시키거나 프레임 크기를 조정할 수 없습니다. 예를 들어, 프레임의 레이블 위젯이 너무 길거나 짧더라도 창 프레임은 동일하게 유지됩니다.

프레임 크기 조정 가능 방법

resizable(width= , height=)widthheight 에서 크기를 조절할 수있는 프레임 윈도우 크기를 설정합니다.

resizable(width = False)는 창 너비 만 고정시키는 반면 resizable(height = False)는 창 높이 만 고정합니다. 전체 창 크기는 resizable(width=False, height=False)또는 간단히 resizable(False, False)를 사용하여 고정됩니다.

try:
    import Tkinter as tk
except:
    import tkinter as tk


app = tk.Tk()
app.title("Frame Window Size Frozen")
app.geometry("300x200")

app.resizable(width=False, height=False)
app.mainloop()

minsizemaxsize 프레임

minsizemaxsize 메소드는 일반적으로 최소 및 최대 창 크기를 설정하는 데 사용되지만 최소 및 최대 크기를 동일하게 설정하면 창 크기를 고정시킬 수도 있습니다.

try:
    import Tkinter as tk
except:
    import tkinter as tk


app = tk.Tk()
app.title("Frame Window Size Frozen")

app.minsize(width=600, height=400)
app.maxsize(width=600, height=400)
app.mainloop()
작가: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook

관련 문장 - Tkinter Geometry