/hichesslib

hichesslib is a cross-platform Python GUI chess library.

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

hichesslib

PyPI version fury.io Build Status Coverage Status

Description

hichesslib is a cross-platform Python GUI chess library based on python-chess and PySide2. The library comes with a board widget that supports the chess rules and provides a set of interactions with the cells of the board and with the board itself including drag and drop, cell marking, piece movement, board flipping and more.

Dependencies

Requires python version >= 3.6. For other dependencies see requirements file.

Usage

Installation

git clone https://github.com/H-a-y-k/hichesslib

cd hichesslib

python3 -m pip install -r --requirements.txt

Initialization

To start using the library you need to create a PySide2 application. The library's widgets can be used like any Qt widget.

>>> import hichess
>>> from PySide2.QtWidgets import QApplication
>>> import sys
>>>
>>> if __name__ == "__main__":
...     app = QApplication(sys.argv)
...     boardWidget = hichess.BoardWidget()
...     boardWidget.show()
...     sys.exit(app.exec_())

Features

CellWidget

  • CellWidget can contain any chess piece.
  • Can be marked. Marked cell widgets are easily customizable.
  • Can be highlighted to display the legal moves on the board.

BoardWidget

  • BoardWidget supports all the chess rules.
  • Is easily customizable.
  • Supports rotation.
  • Supports drag and drop.
  • Games are easily traversable.
  • Interactions can be limited to only one side or for all sides (the latter is for read only boards).
  • Notifies about the game status (draw/stalemate/checkmate).

Documentation

The the documentation is located in docs.

Problems and limitations

  • In order to make CellWidget graphically customizable, after each property change, the methods unpolish and polish are called, which significantly slows down the interactions with CellWidget.

Examples

See examples folder.

Status

The library has been tested on Windows7, Windows10, Fedora 31.

Tests

Unittests are done with the unittest framework. Tests are located in hichesslib/test/.

License

hichesslib is licensed under GPLv3.0+ license. See license file.