Skip to main content

PyQtGameBoard

PyQt5 widget that draws a board on the screen to include in games or map drawing application.

Version

0.2

0.2.6 Created QGameboard parent class for optimization and customization 0.2.5 Added optional size parameter for the size of the tiles Added a rectangle board changed pip name to pyqt-gameboard 0.2.4 removed some prints 0.2.3 fixed selection deleting previous overlays split mousepress method so its easier to subclass adding line of sight line return list of tiles touched by line of sight

0.2.2 Redone building board, zooming in / out and added selection of tile with drawing adjacent tiles

Install

pip install pyqt-gameboard

Import

Directly usable

import the directly usable boards

from pyqtgameboards.gameboards import QRectangleboard
from pyqtgameboards.gameboards import QHexagonboard

Generic parent class for custom shape grids

or import the parent class QGameboard to create a different style map than the defaults

from pyqtgameboards.gameboard import QGameboard

make sure to super the methods that need specific shape implementation

add_shape_to_scene # logic for adding a shape to a grid
get_adjacent_tiles # logic for determining the adjacent tiles

How to

to try out, copying the following to open a widget with a hexagon board This is a gameboard of 20 rows and 10 columns (feels like 20, as it only counts tiles at the same height) This example creates designated tiles that receive a green fill with a thick green line

import sys

from PyQt5 import QtWidgets, QtGui, QtCore

from pyqtgameboards.gameboard import QHexagonboard

if __name__ == '__main__':

    overlays = []

    overlay1brush = QtGui.QBrush(QtGui.QColor(0,255,0,150))
    overlay1pen = QtGui.QPen(QtGui.QColor(0,255,0), 3, QSolidLine)

    overlay1dict = {
        "Brush": overlay1brush,
        "Pen": overlay1pen,
        "Positions": [
            [1, 1], 
            [2, 1],
            [1, 2],
            [3, 3],
            ],
        }

    overlays.append(overlay1dict)

    global app
    app = QtWidgets.QApplication(sys.argv)
    global main
    main = QtWidgets.QMainWindow()

    main.setCentralWidget(QHexagonboard(
        horizontal = True, 
        rows = 20, 
        columns = 10,
        overlays = overlays,
        ))

    main.showMaximized()
    sys.exit(app.exec_())

Licence

Licensed under GPL-3.0-or-later, see LICENSE file for details.

Copyright © 2020 Michael-Yongshi.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Metadata

Release files for pyqt-gameboard 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqt-gameboard 0.2.6
File Size Uploaded
pyqt-gameboard-0.2.6.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyqt-gameboard 0.2.6
File Interpreter ABI Platform
pyqt_gameboard-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 27.8 kB

Release files / pyqt-gameboard-0.2.6.tar.gz

Download URL pyqt-gameboard-0.2.6.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
eda13d4bd16739f59744b2c478db68827367563c8749a83b7292ceef7ef4eed8
BLAKE2b-256 checksum
How to use checksums
9b3cbf437c591d150d59d1b0123f5775912f582633670249d3c00deee46be275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.8

Release files / pyqt_gameboard-0.2.6-py3-none-any.whl

Download URL pyqt_gameboard-0.2.6-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48d13b47db847f8cbdf89ef29f90c0dddd48dec8379bf4291c02fd0dfe3631c0
BLAKE2b-256 checksum
How to use checksums
9926e5dd91403b347f54646d66b0ded46f5b2a7e7225f2d9ce918f7a904cbdca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page