[Python] tkinter를 이용하여 Hello World 만들기



import tkinter as tk

root = tk.Tk()
"Tkinter를 초기화하기 위해 Tk Root 위젯을 만듬."
"Root 위젯은 가장 먼저 만들어져야 하며 프로그램에 하나만 존재함"
root.title('Test')
"Root 위젯의 타이틀 설정함"

w = tk.Label(root, text="Hello World!\nWelcome")
"Root 위젯의 자식으로 Label 위젯을 만듬"

w.pack()
"pack()을 호출하여 주어진 텍스트에 맞게 크기를 조절하고, 텍스트를 업데이트함"
root.mainloop()
" 윈도우를 닫을 때까지 이벤트 루프를 실행함"

댓글

이 블로그의 인기 게시물

[Python] Tkinter를 활용한 Text Console 출력

[Python] Tkinter를 활용하여 Text 강조(Highlight)하기

[Python] Tkinter를 활용하여 Entry 값 계산하여 Label에 출력