Lecture 기본 위젯 - Label
Views 99
• Comments 0
• Last Updated at 6 months ago
- 윈도우 프로그램
레이블
from tkinter import *
def func(event):
messagebox.showinfo('키 눌림', '키 :'+chr(event.keycode))
win = Tk()
label1 = Label(win, text = '키가 눌림')
label2 = Label(win, text = '파이썬 공부', font=('arial', 30), fg = 'blue')
label1.pack()
label2.pack()
win.mainloop()
레이블에 그림 입히기
from tkinter import *
from PIL import ImageTk, Image
win = Tk()
#photo = Image.open('D://전기전자//test.gif')
photo = Image.open('D://전기전자//tiger.bmp') #1
test = ImageTk.PhotoImage(photo) #2
lbl = Label(win, image=test) #3
lbl.image = test #4
lbl.pack()
win.mainloop()
- 이미지를 불러온다.
- 이미지를 포토이미지로 바꿔준다.
- 레이블에 이미지를 넣는다.
- 레이블에 이미지를 붙인다.
previous article
next article
Login to write a comment.