Label에 문장을 설정하려면 Label 인스턴스의 text 속성을 지정해야 하는데 여기에는 여러 가지 방법이 있다.
Label 인스턴스를 생성할 때, text 속성을 설정하는 방법
from tkinter import Tk, Label
if __name__ == "__main__":
root = Tk()
root.title("Label 인스턴스를 생성할 때, text 속성을 설정하는 방법")
textLabel = Label(root, text="고양이")
textLabel.pack()
root.mainloop()
생성된 Label 인스턴스에 딕셔너리 변수처럼 text 속성을 설정하는 방법
from tkinter import Tk, Label
if __name__ == "__main__":
root = Tk()
root.title("생성된 Label 인스턴스에 딕셔너리 변수처럼 text 속성을 설정하는 방법")
textLabel = Label(root)
textLabel["text"] = "염소"
textLabel.pack()
root.mainloop()
config 메소드를 이용한 방법
from tkinter import Tk, Label
if __name__ == "__main__":
root = Tk()
root.title("config 메소드를 이용한 방법")
textLabel = Label(root)
textLabel.config(text="닭")
textLabel.pack()
root.mainloop()

