From e7ea57db49d52e18e6f2ba73f7c78f620b5c0bff Mon Sep 17 00:00:00 2001 From: Talley Lambert Date: Sat, 24 Apr 2021 15:32:07 -0400 Subject: [PATCH] add screenshots --- .github/workflows/test_and_deploy.yml | 11 +++++++++ examples/screenshots.py | 35 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/screenshots.py diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index b307ec8..5183e7c 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -93,6 +93,17 @@ jobs: - name: Coverage uses: codecov/codecov-action@v1 + - name: Screenshots + run: | + pip install . ${{ matrix.backend }} + python examples/screenshots.py + + - uses: actions/upload-artifact@v2 + with: + name: screenshots + path: screenshots + + deploy: # this will run when you have tagged a commit, starting with "v*" # and requires that you have put your twine API key in your diff --git a/examples/screenshots.py b/examples/screenshots.py new file mode 100644 index 0000000..f48900a --- /dev/null +++ b/examples/screenshots.py @@ -0,0 +1,35 @@ +import pathlib +from itertools import product + +from pyqrangeslider import QRangeSlider +from pyqrangeslider.qtcompat.QtCore import Qt +from pyqrangeslider.qtcompat.QtWidgets import QApplication + +dest = pathlib.Path("screenshots") +dest.mkdir(exist_ok=True) + +app = QApplication([]) + +orientations = ("horizontal", "vertical") +ticks = ("NoTicks", "TicksAbove", "TicksBelow") + +variants = [ + # (min, max), orient, ticks, + ((20, 80), "horizontal"), + ((20, 80), "vertical"), +] + +for orient, tick in product(orientations, ticks): + slider = QRangeSlider(getattr(Qt, orient.title())) + slider.setRange(0, 100) + slider.setValue((20, 80)) + slider.setTickPosition(getattr(slider, tick)) + slider.activateWindow() + if orient == "horizontal": + slider.setFixedWidth(300) + else: + slider.setFixedHeight(200) + app.processEvents() + fname = dest / f"grab_{orient[:1]}_{tick}.png" + slider.grab().save(str(fname)) + slider.close()