tkinter 코드 중 질문 드립니다.

조회수 707회

from tkinter import * from time import *

전역 변수 선언 부분

fnameList = ["test1.gif", "test2.gif", "test3.gif", "test4.gif", "test5.gif", "test6.gif", "test7.gif", "test8.gif", "test9.gif",] photoList = [None] * 9 num = 0

함수 선언 부분

def clickNext() : global num num += 1 if num > 8 : num = 0 photo = PhotoImage(file = "chapter10/gif/" + fnameList[num]) pLabel.configure(image = photo) pLabel.image = photo

def clickPrev() : global num num -= 1 if num < 0 : num = 8 photo = PhotoImage(file = "chapter10/gif/" + fnameList[num]) pLabel.configure(image = photo) pLabel.image = photo

메인 코드 부분

window = Tk() window.geometry("700x500") window.title("사진 앨범 보기")

btnPrev = Button(window, text = "<< 이전", command = clickPrev) btnNext = Button(window, text = "다음 >>", command = clickNext)

window.bind("", clickNext) # PageUp key click window.bind("", clickPrev) # PageDown key click

photo = PhotoImage(file = "chapter10/gif/" + fnameList[0]) pLabel = Label(window, image = photo)

btnPrev.place(x = 250, y = 10) btnNext.place(x = 400, y = 10) pLabel.place(x = 15, y = 50)

window.mainloop()

사진이 넘어가는 프로그램을 검토 중인데... 함수 정의 부분에 있는 pLabel.configure(image = photo) pLabel.image = photo 이 두 줄의 코드가 어떤 역할을 하는지 알 수 있을까요? 위의 코드는 사진을 새롭게 바꾸어주는 역할 같은데... 아래의 pLabel.image = photo 코드의 역할이 잘 와닿지 않네요. 두 줄의 코드가 어떤 기능을 하는지 궁금합니다.

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)