Chess Board

The use of the chessboard requires a mouse or a mousepad. A piece is moved like that:

  • mouse-left-press: begin move of selected piece

  • mouse-left-release: end move

For training purposes, several helpers are available.

Warn of Danger

The Warn of Danger is enabled by the Game/Warn of Danger action. It runs as follows:

  1. assign material scores to each attack and reply for every ply

  2. create a combined list of attacks and replies (cheapest first)

  3. create a list of total scores for every ply

Effect on other pieces like discovered check are not considered. An example:

Warn of Danger

Obviously, the rook at b8 is danger.

Move Options

The Move Options are enabled by the Game/Show Move Options action. By pressing the left mouse button at b8, we see:

Move Options

It seem that b8-d8 is the best move, but it is dubious …

class qboardviewclass.QBoardViewClass(parent=None)[source]

The chessboard is based on Qt’s QGraphicsView.

__init__(parent=None) None[source]
setup(notifyNewGameNodeSignal: pyqtSignal | None = None, notifyGameNodeSelectedSignal: pyqtSignal | None = None, materialLabel: QLabel | None = None, squareLabel: QLabel | None = None, turnFrame: QFrame | None = None, hintLabel: QLabel | None = None, flipped: bool = False) None[source]

Set up of the game editor

Parameters:
  • notifyNewGameNodeSignal – signal to be emitted if a move is added

  • notifyGameNodeSelectedSignal – signal to be emitted if a game node is selected

  • materialLabel – label showing the material budget

  • squareLabel – label showing the square under mouse pointer (usually in the status bar)

  • turnFrame – frame showing the color of player making the move

  • hintLabel – label showing the engine’s hints and scores (usually in the status bar)

  • flipped – if True, the square a1 is on top

setHint(enableHint: int = 0, enableScore: bool = False, engine: ChessEngine | None = None) None[source]

Controls the usage of the hint label

Parameters:
  • enableHint – If True, the hintLabel shows the engine hint

  • enableScore – If True, the hintLabel shows the engine scores

  • engine – engine to be used (required, if enableHint or enableScore

setFlipped(enable: bool) None[source]

Controls the board orientation

Parameters:

enable – if True, the square a1 is on top

setDrawOptions(enable: bool) None[source]

Controls the draw options. Draw options are shown when mouse-left-press on a piece

Parameters:

enable – if True, the draw options are enabled

setWarnOfDanger(enable: bool) None[source]

Controls the warn of danger, i.e. shows attacked pieces

Parameters:

enable – if True, the warn of danger is enabled

set_fen(fen: str) None[source]

Configures the chessboard

Parameters:

fen – position in Forsyth-Edwards Notation .. _Forsyth-Edwards: https://github.com/fsmosca/PGN-Standard

setGameNode(gameNode: GameNode) None[source]

Sets the game node displayed by the chessBoard

:param gameNode : game node to be displayed

nextMove() None[source]

Go 1 move forward, if possible

previousMove() None[source]

Go 1 move backward, if possible

resizeEvent(self, QResizeEvent)[source]
keyPressEvent(self, QKeyEvent)[source]
class qboardviewclass.Piece(symbolName: str, size: int, parent=None)[source]

Internal class

__init__(symbolName: str, size: int, parent=None) None[source]
symbol values (according to PGN spec)

p,P = white pawn, black ~ n,N = white knight, black ~ b,B = white bishop, black ~ r,R = white rook, black ~ q,Q = white queen, black ~ k,K = white king, black ~

class qboardviewclass.Game(parent=None)[source]

Internal class

__init__(parent=None) None[source]
mouseDoubleClickEvent(self, QGraphicsSceneMouseEvent)[source]
eventFilter(self, QObject, QEvent) bool[source]
mousePressEvent(self, QGraphicsSceneMouseEvent)[source]
mouseReleaseEvent(self, QGraphicsSceneMouseEvent)[source]