Package sudoku :: Module sudoku_GUI :: Class Sudoku_GUI
[hide private]
[frames] | no frames]

Class Sudoku_GUI

source code

object --+
         |
        Sudoku_GUI

This class contains the user interface for the Sudoku game program.

Instance Methods [hide private]
 
__init__(self, chart)
Creates and makes visible a new frame, which displays the given sudoku chart.
source code
 
create_components(self)
Creates components for the GUI's application frame.
source code
 
number_entered(self, event)
Event handler method: reacts to the user signaling that new text has been entered to a text field by reading whatever is in the field and updating the model accordingly.
source code
 
input_received(self, field)
Examines the contents of the given text field and tries to update the game model (the Sudoku chart) and lock the field (set it as uneditable).
source code
 
read_input(self, field)
Parses the contents of the given text field as an integer that is to be stored in a Sudoku cell.
source code
 
try_to_set_number(self, row, column, new_number)
Tries to update the game model (the Sudoku chart) by filling the cell at the given position with the given number.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, chart)
(Constructor)

source code 

Creates and makes visible a new frame, which displays the given sudoku chart.

Parameters:
  • chart - a sudoku grid to be displayed in a frame
Overrides: object.__init__

number_entered(self, event)

source code 

Event handler method: reacts to the user signaling that new text has been entered to a text field by reading whatever is in the field and updating the model accordingly.

Parameters:
  • event - the event that contains the widget whose contents should be examined

input_received(self, field)

source code 

Examines the contents of the given text field and tries to update the game model (the Sudoku chart) and lock the field (set it as uneditable). If the input is not parseable, clears the field instead. If a mistake was made by the user (new number violates Sudoku rules), the method causes the program to exit.

Parameters:
  • field - the field that should be read

read_input(self, field)

source code 

Parses the contents of the given text field as an integer that is to be stored in a Sudoku cell.

Parameters:
  • field - the field that should be read
Returns:
the integer input read from the field, or zero if the input is not parseable or not between 0 and chart size - 1

try_to_set_number(self, row, column, new_number)

source code 

Tries to update the game model (the Sudoku chart) by filling the cell at the given position with the given number. If the indicated cell is not empty to begin with, the method does nothing. If the number placement violates Sudoku rules, the method causes the program to exit.

Parameters:
  • row - a row index (between 0 and chart size - 1)
  • column - a column index (between 0 and chart size - 1)
  • new_number - a number to place in the indicated cell