728x90
반응형
from tkinter import *
from tkinter.filedialog import *
def func_open():
filename = askopenfilename(parent=window, filetypes=(("GIF 파일","*.gif"), ("모든 파일","*.*")))
photo = PhotoImage(file=filename)
pLabel.configure(image=photo)
pLabel.image = photo
def func_exit():
window.quit()
window.destroy()
def keyPressHandler(event, photo):
if (event.keycode==38): #아스키코드 38 는 ↑ 키
# print('Up',photo)
photo_new = photo.zoom(2, 2) # x, h
# photo = photo1._PhotoImage__photo.zoom(2,2)
elif (event.keycode==40): #아스키코드 40 는 ↓ 키
# print('Down')
photo_new = photo.subsample(2, 2)
# photo = photo1._PhotoImage__photo.subsample(2,2)
pLabel.configure(image = photo_new)
pLabel.image = photo_new
window = Tk()
window.geometry("500x500")
window.title("몀화 감상하기")
photo = PhotoImage()
pLabel = Label(window, image=photo)
pLabel.pack(expand = 1, anchor=CENTER)
mainMenu = Menu(window)
window.config(menu=mainMenu)
fileMenu = Menu(mainMenu)
mainMenu.add_cascade(label="파일",menu=fileMenu)
fileMenu.add_command(label="파일 열기", command=func_open)
fileMenu.add_separator()
fileMenu.add_command(label="프로그램 종료", command=func_exit)
window.bind("<KeyPress>",lambda event: keyPressHandler(event, pLabel.image))
window.mainloop()
728x90
반응형
'프로그램' 카테고리의 다른 글
[C언어] 문자열 입력 받아 문자,숫자,기타 문자 개수 출력 (0) | 2023.05.23 |
---|---|
[파이썬] 문제 : datascience Table 처리(nba데이터) (0) | 2023.05.22 |
[파이썬] 문제 : 커피 판매 키오스크 (0) | 2023.05.21 |
[파이썬] 문제 : 1~100까지의 정수 난수 10개를 만들어 최소값, 최대값 찾기 (0) | 2023.05.20 |
[파이썬] 문제 : 방정식 함수 만들기 (0) | 2023.05.19 |
댓글