MapleStory Finger Point Cute Line Smiley Blinking Hello Kitty Angel MapleStory Finger Point

πŸ’Ž Python/Python κ°œλ…μ •λ¦¬

Λšβ‚Šβœ©β€§β‚Š μœˆλ„ ν”„λ‘œκ·Έλž˜λ° Λšβ‚Šβœ©β€§β‚Š

HYEJU01 2024. 4. 8. 00:55

β–Ά μœˆλ„μ°½ ꡬ성

  • tkinter 은 νŒŒμ΄μ¬μ—μ„œ GUI λͺ¨λ“ˆμ„ μ œκ³΅ν•΄μ£ΌλŠ” ν‘œμ€€ μœˆλ„ 라이브러리
from tkinter import *

window = Tk()  
#Tk()λŠ” 기본이 λ˜λŠ” μœˆλ„λ₯Ό λ°˜ν™˜ν•¨
#λ£¨νŠΈμœˆλ„, λ² μ΄μŠ€μœˆλ„λΌκ³  뢀름 / μ‹€ν–‰ν•˜λ©΄ μœˆλ„μ°½μ΄ 화면에 λ‚˜μ˜΄

window.mainloop()
#10-2

from tkinter import *

window = Tk()
window.title("μœˆλ„ μ°½ μ—°μŠ΅")
window.geometry("400x100")
window.resizable(width = FALSE, height = FALSE)

window.mainloop()

β–Ά λ ˆμ΄λΈ”

  • 문자 ν‘œν˜„ν•  수 μžˆλŠ” μœ„μ ―
  • Label(λΆ€λͺ¨μœˆλ„, μ˜΅μ…˜ ... )
from tkinter import * 
window = Tk()

photo = PhotoImage(file = "gif/dog.gif")
label1 = Label(window,image = photo)  #이미지λ₯Ό κΈ€μž λŒ€μ‹  μ‚¬μš©

label1.pack()

window,mainloop()

β–Ά λ²„νŠΌ

  • λ²„νŠΌ 클릭 νš¨κ³Όμ™€ μ§€μ •ν•œ μž‘μ—…μ΄ μ‹€ν–‰λ˜λŠ” μœ„μ ―
  • Button(λΆ€λͺ¨μœˆλ„, μ˜΅μ…˜ ... )

β–Άν‚€λ³΄λ“œμ™€ 마우슀 이벀트 처리

#10-15

from tkinter import*

##ν•¨μˆ˜μ„ μ–ΈλΆ€λΆ„##
def clickMouse(event):
    txt=""
    if event.num == 1:
        txt += "마우슀 μ™Όμͺ½ λ²„νŠΌμ΄ ("
    elif event.num == 3:
        txt +="마우슀 였λ₯Έμͺ½ λ²„νŠΌμ΄ ("
        
    txt += str(event.y) + "," + str(event.x) + ")μ—μ„œ 클릭됨"
    
    label1.configure(text = txt)
    
##메인 μ½”λ“œ λΆ€λΆ„ ##

window = Tk()
window.geometry("400x400")

label1 = Label(window, text = "이곳이 λ°”λ€œ")

window.bind("<Button>",clickMouse)

label1.pack(expand = 1, anchor = CENTER)
window.mainloop()
#10-16

from tkinter import*
from tkinter import messagebox

##ν•¨μˆ˜μ„ μ–ΈλΆ€λΆ„##
def clickMouse(event):
   messagebox.showinfo("ν‚€λ³΄λ“œμ΄λ²€νŠΈ","눌린 ν‚€ : "+ chr(event.keycode))
    
##메인 μ½”λ“œ λΆ€λΆ„ ##

window = Tk()

window.bind("<Key>",keyEvent)

window.mainloop()

[SELF STUDY 10-4]

from tkinter import*
from tkinter import messagebox

##ν•¨μˆ˜μ„ μ–ΈλΆ€λΆ„##
def keyEvent(event):
    if event.keycode == 37:
        key = "μ™Όμͺ½"
    elif event.keycode == 38:
        key = "μœ„μͺ½"
    elif event.keycode == 39:
        key = "였λ₯Έμͺ½"
    elif event.keycode == 40:
        key = "μ•„λž˜μͺ½"
        
    messagebox.showinfo("ν‚€λ³΄λ“œμ΄λ²€νŠΈ","눌린 ν‚€ : " + "shift + " + key + "ν™”μ‚΄ν‘œ")      

    

##메인 μ½”λ“œ λΆ€λΆ„ ##

window = Tk()

window.bind( "<Shift-Up>",keyEvent)
window.bind( "<Shift-Down>",keyEvent)
window.bind( "<Shift-Left>",keyEvent)
window.bind( "<Shift-Right>",keyEvent)

window.mainloop()
from tkinter import*
from tkinter.simpledialog import *

##ν•¨μˆ˜μ„ μ–ΈλΆ€λΆ„##
window = Tk()
window.geometry("400x100")

label1=Label(window, text="μž…λ ₯λœκ°’")
label1.pack()

value = askinteger("ν™•λŒ€λ°°μˆ˜","μ£Όμ‚¬μœ„ 숫자 (1~6)을 μž…λ ₯ν•˜μ„Έμš”",minvalue=1,maxvalue=6)

label1.configure(text=str(value))
window.mainloop()
   
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("<Up>", clickNext)      # PageUp key click
window.bind("<Down>", 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()