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.
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 crash8229.
Project details
Release history Release notifications | RSS feed
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.1.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file qtpy-led-0.1.1.tar.gz
.
File metadata
- Download URL: qtpy-led-0.1.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1f3ba575f59096bce7464a7de192b491feb6c27a00177bb5ffe47e2b3f6ddf4 |
|
MD5 | b01ebdc0fd1528a99204ee7c1b8b2f85 |
|
BLAKE2b-256 | 728d439f6992335b8ae0da20bfc38b7c3a9a569d61906995d31256c60a651a31 |
File details
Details for the file qtpy_led-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: qtpy_led-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.0 CPython/3.10.3 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2952751fbce6b456667646dff6cecd7ce4fabf799f3873608923e0422385994b |
|
MD5 | c9cc6a8a423f06dc1ade270f79f6c2a3 |
|
BLAKE2b-256 | e49c2806e0dbd0b19b3eb5d4687ae53a3edeeb10872dbc24728b83cc7108074a |