Python Chess Widgets
A modern, feature-rich chess board widget for PySide6 applications, designed to mimic the visual style and user experience of Lichess. It is built on top of the powerful python-chess library.
Features
- Lichess-like Aesthetics: Uses standard Lichess colors, SVG piece sets, and highlighting styles.
- Interactive: Supports both drag-and-drop and click-to-move interactions.
- Smooth Animations: Piece movements are animated for a better user experience.
- Visual Indicators:
- Legal move highlights (dots for empty squares, rings for captures).
- Last move highlighting.
- Check indicator (red blurred glow behind the king).
- Selected piece and hover highlights.
- Responsive: The board maintains its square aspect ratio and centers itself within the widget, scaling to fit the available space.
- Board Flipping: Easily toggle between White and Black perspectives.
- Type Safe: Fully typed codebase with
mypysupport (PEP 561 compliant).
Installation
You can install the package from PyPI:
pip install chess-widgets
Usage
Here is a simple example of how to use the BoardWidget in a PySide6 application:
import sys
import chess
from PySide6.QtWidgets import QApplication, QMainWindow
from chess_widgets import BoardWidget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Chess Board Example")
self.resize(600, 600)
# Create the widget
self.board_widget = BoardWidget()
self.setCentralWidget(self.board_widget)
# Connect to the move signal
self.board_widget.move_played.connect(self.on_move_played)
# Optional: Set an initial board state (defaults to starting position)
# self.board_widget.set_board(chess.Board())
def on_move_played(self, move: chess.Move, move_info: dict):
interactive = move_info.get("interactive", False)
print(f"{'Interactive' if interactive else 'Programmatic'} move: {move}")
# The widget updates its internal board automatically for user moves.
# You can access the board state via:
# print(self.board_widget._board.fen())
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
A more complex example with move history navigation, board flipping, and random moves played for the opposite color can be found in the examples/demo.py file.
API Overview
set_board(board: chess.Board): Sets the board state to display.set_flipped(flipped: bool): Sets the board orientation (Truefor Black at bottom,Falsefor White at bottom).play_move(move: chess.Move, animate: bool = True, interactive: bool = False): Programmatically make a move on the board, optionally with animation.undo_move(move: chess.Move, animate: bool = True): Programmatically unmake the last move on the board, optionally with animation.move_played(chess.Move, dict): Emitted when a move is played. The dictionary contains move information (e.g.,{'interactive': True}).move_undone(chess.Move): Emitted when a move is undone.
Contributing
We welcome contributions! Please see CONTRIBUTING.md for details on how to set up your development environment and submit changes.
License
Metadata
Release files for chess-widgets 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chess_widgets-0.5.0.tar.gz | 25.0 kB | With provenance | Details for chess_widgets-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chess_widgets-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for chess_widgets-0.5.0-py3-none-any.whl |
Total release size: 43.1 kB
Release files / chess_widgets-0.5.0.tar.gz
| Download URL | chess_widgets-0.5.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a27382de47275a4612188b04873e9a51f527ec8d9b09a6f734b802400e6b53eb
|
|
BLAKE2b-256 checksum How to use checksums |
fc39200fd9e0aec356140b898b79331a8f33c1282b5fe0c6d160d2b4c4acbbb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2025.
Transparency logRelease files / chess_widgets-0.5.0-py3-none-any.whl
| Download URL | chess_widgets-0.5.0-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
120bbd7516a57736d00a9d27384f0e2b19395c83cc78a2ae71a1f379e746c14c
|
|
BLAKE2b-256 checksum How to use checksums |
3d6034cf91c7aa36713938bb15c8fffbe3297c55613c626deda4a0d28189f27a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2025.
Transparency logSecurity for chess-widgets 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for chess_widgets-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 24, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.