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

[tkinter] 04. input박스 만들기

by 한코코 2024. 4. 13.

버튼을 누르면 입력된 값을 출력하기

from tkinter import *

root = Tk()

# input 박스 생성
e = Entry(root, width=50, bg="black", fg="white", borderwidth=30, border=1)
e.pack()
# 입력하기 전에 보여주는 input 안의 값
e.insert(0,"Enter Your Name: ")


def myClick():
    hello = "Hello "+e.get()
    myLabel = Label(root, text=hello)
    myLabel.pack()

myButton = Button(root, text="Enter Your Name", padx=50, pady=50, command=myClick)
myButton.pack()

root.mainloop()

 

 

출처 : https://www.youtube.com/watch?v=7A_csP9drJw&list=PLCC34OHNcOtoC6GglhF3ncJ5rLwQrLGnV&index=4

댓글