본문 바로가기
프로그래밍/python

[tkinter] 02. 행렬 지정하기(row, column)

by 한코코 2024. 4. 13.

from tkinter import *

root = Tk()

# Creating LabelWidget
myLabel1 = Label(root, text="Hello World")
myLabel2 = Label(root, text="My name is Hancoco")

myLabel1.grid(row=0, column=0)
myLabel2.grid(row=1, column=1)

root.mainloop()

 

 

 

row와 column은 상대적이다.

myLabel1.grid(row=0, column=0)
myLabel2.grid(row=1, column=5)

이렇게 놓아도 위 이미지처럼 보이는데, 이유는 상대적이기 때문이다.

1열와 5열에 데이터가 있어도 2,3,4열에는 데이터가 없기때문에 무시한다.

 

 

 

줄여서 한 줄에 쓰는 법

# Creating LabelWidget
myLabel1 = Label(root, text="Hello World").grid(row=0, column=0)
myLabel2 = Label(root, text="My name is Hancoco").grid(row=1, column=5)

이렇게 줄여써도 무관하다.

 

 

 

출처 : https://www.youtube.com/watch?v=BSfbjrqIw20&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV&index=2

'프로그래밍 > python' 카테고리의 다른 글

[tkinter] 04. input박스 만들기  (0) 2024.04.13
[tkinter] 03. 버튼 만들기  (0) 2024.04.13
[tkinter] 01. hello 창 띄우기  (0) 2024.04.13
chatGPT API  (0) 2024.04.12
파이썬 기초 진행기(수시 업데이트 예정)  (0) 2024.04.11

댓글