Skip to main content

Simple LED widget for QyPt

Project description

qtpy_led

Simple LED widget for QtPy.
Forked from pyqt_led by Neur1n and modified to work with QtPy.

on off

Table of Contents

Installation

pip

$ pip install qtpy-led

poetry

$ poetry install

Usage

The following example is also provided in the package, and will result in the screenshots shown above.

from qtpy.QtCore import Qt
from qtpy.QtWidgets import QApplication
from qtpy.QtWidgets import QGridLayout
from qtpy.QtWidgets import QWidget
from qtpy_led import Led
import numpy as np
import sys


class Demo(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self._shape = np.array(["capsule", "circle", "rectangle"])
        self._color = np.array(
            ["blue", "green", "orange", "purple", "red", "yellow"]
        )
        self._layout = QGridLayout(self)
        self._create_leds()
        self._arrange_leds()

    def keyPressEvent(self, e):
        if e.key() == Qt.Key_Escape:
            self.close()

    def _create_leds(self):
        for s in self._shape:
            for c in self._color:
                exec(
                    'self._{}_{} = Led(self, on_color=Led.{}, \
                      shape=Led.{}, build="debug")'.format(
                        s, c, c, s
                    )
                )
                exec("self._{}_{}.setFocusPolicy(Qt.NoFocus)".format(s, c))

    def _arrange_leds(self):
        for r in range(3):
            for c in range(6):
                exec(
                    "self._layout.addWidget(self._{}_{}, {}, {}, 1, 1, \
                      Qt.AlignCenter)".format(
                        self._shape[r], self._color[c], r, c
                    )
                )
                c += 1
            r += 1


app = QApplication(sys.argv)  # type: ignore
demo = Demo()
demo.show()
sys.exit(app.exec_())

License

MIT License. Copyright (c) 2023 Mike Umana.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qtpy-led-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

qtpy_led-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file qtpy-led-0.1.0.tar.gz.

File metadata

  • Download URL: qtpy-led-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.3 Windows/10

File hashes

Hashes for qtpy-led-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5b4e0d1c27669760e3563388db8b5cb17c9aeb6dcd13e1b4f227eda9d0b4a34c
MD5 24ccf8d6c44f2551cde748737d9dde3f
BLAKE2b-256 b7ebfdc0b34ba11fcd054817aad16df608ac53c9070d9f83e1c08b9ebffdcd19

See more details on using hashes here.

File details

Details for the file qtpy_led-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qtpy_led-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.3 Windows/10

File hashes

Hashes for qtpy_led-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97efc690ce281dbcfa6486acc9a15fa9089a4d4bda1f21ddf4e6fed5aec60226
MD5 8c649fb6d1ae8a73e07fe755f811494a
BLAKE2b-256 9b3f56c295e8c3b52503f9af92fc118c501627b89c2638af0a10d5d908912d59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page