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()