Sudoku Showcase
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
sudoku.ui.UI Class Reference

Graphical user interface representing the View layer of the application's Model-View-Controller architecture. More...

Public Member Functions

def __init__ (self, "App" app)
 Creates an instance of UI. More...
 
None run (self)
 Call when ui initialized and ready to go. More...
 
int cellHeight (self)
 Properties. More...
 
int cellWidth (self)
 (readonly property) defines the cell-width by the cell height More...
 
None cellHeight (self, int size)
 Set the property cellHeight. More...
 
Theme theme (self)
 The currently selected Theme. More...
 
None update (self)
 Update functions. More...
 
None onMistake (self)
 Updates the ui and update again after one second. More...
 
None showGameOver (self, str label="Game Over!!!")
 shows the Game-Over-Screen. More...
 
None showGameWin (self, str label="Congratulation!!!")
 Shows the Win-screen. More...
 
None onNewGame (self)
 To call when a new game is started. More...
 
None onKeyboardInput (self)
 Eventhandler on keyboard input TODO implement. More...
 

Public Attributes

 app
 
 menubar
 
 newGame
 
 modesMenu
 
 highlightDigitsVar
 
 highlightRulesVar
 
 themesMenu
 
 themeVar
 
 windowMenu
 
 windowSizeVar
 
 topFrame
 
 gridFrame
 
 bottomFrame
 
 cellHeight
 

Static Public Attributes

tuple DEFAULT_FONT = ('Britannic', 13, 'bold')
 
tuple GAME_END_FONT = ("Courier New", 13, "bold")
 
dictionary CELL_SIZE = {"Small": 1, "Standard": 2, "Large": 3}
 
 DEFAULT_LIGHT_THEME
 

Detailed Description

Graphical user interface representing the View layer of the application's Model-View-Controller architecture.

The UI is responsible solely for visualization and user interaction. It contains no Sudoku rules, solving logic, or gameplay validation. All state changes and logic interactions are delegated to the App controller through public interface functions.

The interface is implemented using tkinter and dynamically creates the window, game grid, menus, digit buttons, status displays, and theme-based visual styling.

The UI follows a pull-based design instead of an event distribution system. Required information is queried from the App whenever the interface updates, while user actions are forwarded back to the App.

The class provides functionality for:

Many internal helper functions are intentionally implemented as nested submethods to improve readability and structure while avoiding an unnecessarily large public interface.

Constructor & Destructor Documentation

◆ __init__()

def sudoku.ui.UI.__init__ (   self,
"App"  app 
)

Creates an instance of UI.

This also creates the window and the main attributes.

Member Function Documentation

◆ cellHeight() [1/2]

int sudoku.ui.UI.cellHeight (   self)

Properties.

(property) the cell-height

Returns
int

◆ cellHeight() [2/2]

None sudoku.ui.UI.cellHeight (   self,
int  size 
)

Set the property cellHeight.

◆ cellWidth()

int sudoku.ui.UI.cellWidth (   self)

(readonly property) defines the cell-width by the cell height

Returns
int

◆ onKeyboardInput()

None sudoku.ui.UI.onKeyboardInput (   self)

Eventhandler on keyboard input TODO implement.

Returns
None

◆ onMistake()

None sudoku.ui.UI.onMistake (   self)

Updates the ui and update again after one second.

NOTE: update itself recolors the cells causing mistakes.

Returns
None

◆ onNewGame()

None sudoku.ui.UI.onNewGame (   self)

To call when a new game is started.

Uses the states provided by the app-object

Returns
None

◆ run()

None sudoku.ui.UI.run (   self)

Call when ui initialized and ready to go.

Returns
None

◆ showGameOver()

None sudoku.ui.UI.showGameOver (   self,
str   label = "Game Over!!!" 
)

shows the Game-Over-Screen.

Parameters
labelstr - the label to show on Game Over
Returns
None

◆ showGameWin()

None sudoku.ui.UI.showGameWin (   self,
str   label = "Congratulation!!!" 
)

Shows the Win-screen.

Parameters
labelstr - the label to show on Game Win
Returns
None

◆ theme()

Theme sudoku.ui.UI.theme (   self)

The currently selected Theme.

Returns
Theme

◆ update()

None sudoku.ui.UI.update (   self)

Update functions.

Updates and colorizes the grid, the digit Buttons. Also updates the mistakes count.

Returns
None

Member Data Documentation

◆ app

sudoku.ui.UI.app

◆ bottomFrame

sudoku.ui.UI.bottomFrame

◆ CELL_SIZE

dictionary sudoku.ui.UI.CELL_SIZE = {"Small": 1, "Standard": 2, "Large": 3}
static

◆ cellHeight

sudoku.ui.UI.cellHeight

◆ DEFAULT_FONT

tuple sudoku.ui.UI.DEFAULT_FONT = ('Britannic', 13, 'bold')
static

◆ DEFAULT_LIGHT_THEME

sudoku.ui.UI.DEFAULT_LIGHT_THEME
static
Initial value:
= Theme(
name = "Light Theme",
fontcolor = HEX("#000000"),
fontcolorCustom = HEX("#3b5bdb"),
background = HEX("#f9f9fa"),
cellBorder = HEX("#d2d2d2"),
gridBackground = HEX("#d2d2d2"),
rulesColor = HEX("#dde3f0"),
activeDigit = HEX("#a6c8ff"),
selectedDigitBackground = HEX("#dde3f0"),
selectedDigitForeground = HEX("#3b5bdb"),
mistake = HEX("#e53935"),
)

◆ GAME_END_FONT

tuple sudoku.ui.UI.GAME_END_FONT = ("Courier New", 13, "bold")
static

◆ gridFrame

sudoku.ui.UI.gridFrame

◆ highlightDigitsVar

sudoku.ui.UI.highlightDigitsVar

◆ highlightRulesVar

sudoku.ui.UI.highlightRulesVar

◆ menubar

sudoku.ui.UI.menubar

◆ modesMenu

sudoku.ui.UI.modesMenu

◆ newGame

sudoku.ui.UI.newGame

◆ themesMenu

sudoku.ui.UI.themesMenu

◆ themeVar

sudoku.ui.UI.themeVar

◆ topFrame

sudoku.ui.UI.topFrame

◆ windowMenu

sudoku.ui.UI.windowMenu

◆ windowSizeVar

sudoku.ui.UI.windowSizeVar

The documentation for this class was generated from the following file: