Hello everyone at DaniWeb,
this is my first post here, so please correct me, if i am wrong in asking this question.
Firstly, i had a 10minute search amongst Google, and here at Daniweb. But im not entirely sure what to search for.

So my question.
i have a Python Tkinter program that has 8 buttons (in a 3x3 square, with the bottom right square missing.)
when one of the buttons is pressed, and if it is directly next to the empty square, it moves into the empty square. im pretty sure i can get the movement correct, but i cant think of a way to determine which button was pressed.
i only want to use a single function for this. but i cant think of how to tell the function to "get" the details of the button that was pressed, is there like a value? or something that will do this for me?

running python 3.2
and tkinter 8.5

James

Okay, so i have a little solution.
i predefine the empty square with:

self.empty_row = 3

and

self.empty_column = 3

then the function at this moment, is:

def move(self):
        self.button8.grid(row = self.empty_row, column = self.empty_column, sticky = W)

but as u can see this will only work for "button8" and not for 1-7.
and then i would need a way, to update the "empty square" variables.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.