Python: How do I make a button freeze when I press it? - Tkinter

This is a memory game where the user selects two buttons (cells). If the two words behind the cells match, the words stays visible else the cells goes hidden and u can't see the words behind them. What I want to do is to make a cell freeze if it shows the word behind it when it is pressed. I want to apply that function to both choice1 and choice2 and even to the pairs that the user have already found.

I have tried to change self.hidden = not self.hidden on line 16 to

if self.hidden:
    self.hidden = False
    self.hidden = False

but that didn't work out pefectly.

Here are the important part:

from tkinter import *
import random

class Cell:
    def __init__(self, word, hidden = True):
        self.word = word
        self.hidden = hidden

    def show_word(self):
        """ Shows the word behind the cell """
        if self.hidden:
            self.hidden = False
            self.hidden = False
        self.button["text"] = str(self)

        if mem.choice1 is None:
            mem.choice1 = self
        elif mem.choice2 is None:
            mem.choice2 = self
            choice1, choice2 = mem.choice1, mem.choice2
            mem.choice1, mem.choice2 = self, None
            self.check(choice1, choice2)

    def check(self, choice1, choice2):
        """ Checks if the chosen words are a pair """
        if choice1.word != choice2.word:
            for cell in (choice1, choice2):
                cell.hidden = True
                cell.button['text'] = str(cell)

    def __str__(self):
        """ Displays or hides the word """
        if self.hidden:
            return "---"
            return self.word

class Memory(Frame):
    """ GUI application that creates a Memory game """
    def __init__(self, master):
        super(Memory, self).__init__(master)
        self.tries = 0
        self.choice1 = None
        self.choice2 = None


You could disable the button when it should not be clickable anymore:

cell.button.config(state = DISABLED)

Need Your Help

Maven tests troubles with SOAP having Java EE 6 dependency

maven soap java-ee-6

I'm finding troubles when trying to use SOAP in tests in a maven project that has Java EE 6 API as a provided-scoped dependency.

Load whole project from Eclipse(about source code)

java eclipse load

I am working on buid a plugin of Eclipse. In one step, i load the project through scan classpath,but the feedback from requirement is:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.