파이썬 같은카드찾기게임 질문

koieonufz의 이미지

from tkinter import *

root = Tk()

count = 0

def change_card_1():
global count
if(count<2):
count = count + 1
image_1 = Label(root, image= photo_17)
image_1.grid(row=0, column=0)

def change_card_2():
global count
if(count<2):
count = count + 1
image_2 = Label(root, image= photo_18)
image_2.grid(row=0, column=1)

def change_card_3():
global count
if(count<2):
count = count + 1
image_3 = Label(root, image= photo_19)
image_3.grid(row=0, column=2)

def change_card_4():
global count
if(count<2):
count = count + 1
image_4 = Label(root, image= photo_20)
image_4.grid(row=0, column=3)

def change_card_5():
global count
if(count<2):
count = count + 1
image_5 = Label(root, image= photo_21)
image_5.grid(row=1, column=0)

def change_card_6():
global count
if(count<2):
count = count + 1
image_6 = Label(root, image= photo_22)
image_6.grid(row=1, column=1)

def change_card_7():
global count
if(count<2):
count = count + 1
image_7 = Label(root, image= photo_23)
image_7.grid(row=1, column=2)

def change_card_8():
global count
if(count<2):
count = count + 1
image_8 = Label(root, image= photo_24)
image_8.grid(row=1, column=3)

def change_card_9():
global count
if(count<2):
count = count + 1
image_9 = Label(root, image= photo_17)
image_9.grid(row=2, column=0)

def change_card_10():
global count
if(count<2):
count = count + 1
image_10 = Label(root, image= photo_18)
image_10.grid(row=2, column=1)

def change_card_11():
global count
if(count<2):
count = count + 1
image_11 = Label(root, image= photo_19)
image_11.grid(row=2, column=2)

def change_card_12():
global count
if(count<2):
count = count + 1
image_12 = Label(root, image= photo_20)
image_12.grid(row=2, column=3)

def change_card_13():
global count
if(count<2):
count = count + 1
image_13 = Label(root, image= photo_21)
image_13.grid(row=3, column=0)

def change_card_14():
global count
if(count<2):
count = count + 1
image_14 = Label(root, image= photo_22)
image_14.grid(row=3, column=1)

def change_card_15():
global count
if(count<2):
count = count + 1
image_15 = Label(root, image= photo_23)
image_15.grid(row=3, column=2)

def change_card_16():
global count
if(count<2):
count = count + 1
image_16 = Label(root, image= photo_24)
image_16.grid(row=3, column=3)

photo_1 = PhotoImage(file = "back.gif")
image_1 = Button(root, image= photo_1, command=change_card_1)
image_1.grid(row=0, column=0)
photo_2 = PhotoImage(file = "back.gif")
image_2 = Button(root, image= photo_2, command=change_card_2)
image_2.grid(row=0, column=1)
photo_3 = PhotoImage(file = "back.gif")
image_3 = Button(root, image= photo_3, command=change_card_3)
image_3.grid(row=0, column=2)
photo_4 = PhotoImage(file = "back.gif")
image_4 = Button(root, image= photo_4, command=change_card_4)
image_4.grid(row=0, column=3)
photo_5 = PhotoImage(file = "back.gif")
image_5 = Button(root, image= photo_5, command=change_card_5)
image_5.grid(row=1, column=0)
photo_6 = PhotoImage(file = "back.gif")
image_6 = Button(root, image= photo_6, command=change_card_6)
image_6.grid(row=1, column=1)
photo_7 = PhotoImage(file = "back.gif")
image_7 = Button(root, image= photo_7, command=change_card_7)
image_7.grid(row=1, column=2)
photo_8 = PhotoImage(file = "back.gif")
image_8 = Button(root, image= photo_8, command=change_card_8)
image_8.grid(row=1, column=3)
photo_9 = PhotoImage(file = "back.gif")
image_9 = Button(root, image= photo_9, command=change_card_9)
image_9.grid(row=2, column=0)
photo_10 = PhotoImage(file = "back.gif")
image_10 = Button(root, image= photo_10, command=change_card_10)
image_10.grid(row=2, column=1)
photo_11 = PhotoImage(file = "back.gif")
image_11 = Button(root, image= photo_11, command=change_card_11)
image_11.grid(row=2, column=2)
photo_12 = PhotoImage(file = "back.gif")
image_12 = Button(root, image= photo_12, command=change_card_12)
image_12.grid(row=2, column=3)
photo_13 = PhotoImage(file = "back.gif")
image_13 = Button(root, image= photo_13, command=change_card_13)
image_13.grid(row=3, column=0)
photo_14 = PhotoImage(file = "back.gif")
image_14 = Button(root, image= photo_14, command=change_card_14)
image_14.grid(row=3, column=1)
photo_15 = PhotoImage(file = "back.gif")
image_15 = Button(root, image= photo_15, command=change_card_15)
image_15.grid(row=3, column=2)
photo_16 = PhotoImage(file = "back.gif")
image_16 = Button(root, image=photo_16, command=change_card_16)
image_16.grid(row=3, column=3)


photo_17 = PhotoImage(file = "nether.gif")
photo_18 = PhotoImage(file = "burk.gif")
photo_19 = PhotoImage(file = "austria.gif")
photo_20 = PhotoImage(file = "aa.gif")
photo_21 = PhotoImage(file = "denmark.gif")
photo_22 = PhotoImage(file = "espa.gif")
photo_23 = PhotoImage(file = "hung.gif")
photo_24 = PhotoImage(file = "ice.gif")

root.mainloop()

파이썬으로 같은카드찾기게임을 만드는데요..
이미지를 삽입하고 이미지 비교후 맞는지 여부에따라 맞으면 그대로 두고 틀리면 다시 뒤집는 방식으로 만들려고 하는데, 어떻게 해야할지 모르겠습니다... 도와주세요 ㅠㅠ..

세벌의 이미지

python 에서는 indentation 중요합니다.
code 태그 안에 소스를 넣어서 질문해 보셔요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.