@YatinBayya/

The Memory Game

Tkinter

No description

fork
loading
Files
  • main.py
  • nohup.out
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import random
import time
from tkinter import Tk,Button,DISABLED

def show_symbol(x,y):
  global first
  global previousX, previousY
  buttons[x,y]['text']=button_symbols
  buttons[x,y].update_idletasks()

  if first:
    previousX = x
    previousY = y
  elif previousX != x or previousY != y:
    if buttons[previousX.previousY]['text']!= buttons[x,y]['text']:
      buttons[previousX.previousY]['text']=''
      buttons[x,y]=''
    else:
      buttons[previousX,previousY]['command'] = DISABLED
      buttons[x,y]['command'] = DISABLED
    first = True

root = Tk()
root.title("Matchmaker")
root.resizable(width=False,height=False)

buttons = {}
first = True
previousX = 0
previousY = 0

button_symbols = {}
symbols=[u'\0024',u'\0024',u'\20AC',u'\20AC',u'\00A3',u'\00A3',u'\00A5',u'\00A5',u'\00A2',u'\00A2',u'\20B9',u'\20B9',u'\20A8',u'\20A8',u'\20B1',u'\20B1',u'\20A9',u'\20A9',u'\0E3F',u'\0E3F',u'\20AB',u'\20AB', u'\20AA', u'\20AA'	]
random.shuffle(symbols)

for x in range(6):
  for y in range(4):
    button = Button(command=lambda x=x, y=y:show_symbol(x,y),width=3,height=3)
    button.grid(column=x,row=y)
    buttons[x,y]=button
    button_symbols[x,y]=symbols.pop()