본문 바로가기
SW 코딩/GUI, tkinter

[파이썬 python] tkinter - 프레임, frame

2021. 11. 13.
반응형

 

 

참고사이트: 유튜브 나도코딩

code - 프레임, frame

12. 프레임, frame.txt
0.00MB

 

code 설명

import tkinter as tk

root = tk.Tk()  # tkinter root창 생성

root.title("tkinter 공부") #창 이름
root.geometry("500x500+200+200") # 창 크기, 가로 x 세로 + 창 출력 위치 좌표

tk.Label(root, text="좋아하는 부류는?").pack(side="top")
tk.Button(root, text="선택하기").pack(side="bottom")

# 과일 프레임
frame_fruit = tk.Frame(root, relief="solid", bd=1)
frame_fruit.pack(side="left", fill="both", expand=True)
#frame_fruit.pack()

tk.Button(frame_fruit, text="사과").pack()
tk.Button(frame_fruit, text="바나나").pack()
tk.Button(frame_fruit, text="파인애플").pack()
tk.Button(frame_fruit, text="귤").pack()

# 브랜드 프레임
frame_brand = tk.LabelFrame(root, text="브랜드")
frame_brand.pack(side="right", fill="both", expand=True)

tk.Button(frame_brand, text="나이키").pack()
tk.Button(frame_brand, text="아디다스").pack()
tk.Button(frame_brand, text="샤넬").pack()

root.mainloop()

 

결과 화면

댓글


loading