Hello ...
I have given code for undo in Sudoku which is:
def get_entry(self, r, c):
"""Get the entry at row r and column c
get_entry(int, int) -> char
"""
return self._game[r][c]
def set_entry(self, r, c, v):
"""Set the entry at row r and column c to v
set_entry(int, int, char) -> void
"""
self._game[r][c] = v
entries = [(r,c)]
if self._do_auto_f ill:
auto = self.auto_fill( )
entries.extend( auto)
self._undo_stac k.append(entrie s)
def undo(self):
"""Undo the last move."""
if self._undo_stac k != []:
entries = self._undo_stac k.pop()
for r,c in entries:
self._game[r][c] = ' '
Then I have been asked define class for a widget that contains button for undoing last move in Sudoku.. This what I have written:
class Commands(Frame) :
def __init__(self, parent):
Frame.__init__( self, parent)
self.button1 = Button(self, text="Undo", width=12, command=self.pr essed)
self.button1.pa ck()
def pressed(self):
print "Button pressed..."
However, I don't know how to call the function undo to link with this Undo button in GUI..
I hope you can help me to sort this problem.
I have given code for undo in Sudoku which is:
def get_entry(self, r, c):
"""Get the entry at row r and column c
get_entry(int, int) -> char
"""
return self._game[r][c]
def set_entry(self, r, c, v):
"""Set the entry at row r and column c to v
set_entry(int, int, char) -> void
"""
self._game[r][c] = v
entries = [(r,c)]
if self._do_auto_f ill:
auto = self.auto_fill( )
entries.extend( auto)
self._undo_stac k.append(entrie s)
def undo(self):
"""Undo the last move."""
if self._undo_stac k != []:
entries = self._undo_stac k.pop()
for r,c in entries:
self._game[r][c] = ' '
Then I have been asked define class for a widget that contains button for undoing last move in Sudoku.. This what I have written:
class Commands(Frame) :
def __init__(self, parent):
Frame.__init__( self, parent)
self.button1 = Button(self, text="Undo", width=12, command=self.pr essed)
self.button1.pa ck()
def pressed(self):
print "Button pressed..."
However, I don't know how to call the function undo to link with this Undo button in GUI..
I hope you can help me to sort this problem.
Comment