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_())
Tips
- If you want to be able to toggle the LED, then either use
setEnable(True)
or pass an empty string to thebuild
argument in Led. - The
status_changed
signal will emit a boolean when the LED's state has changed. - Currently, the only way to shrink the LED beyond the default size is to use
setFixedSize
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.2.tar.gz
(5.4 kB
view details)
Built Distribution
File details
Details for the file qtpy-led-0.1.2.tar.gz
.
File metadata
- Download URL: qtpy-led-0.1.2.tar.gz
- Upload date:
- Size: 5.4 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 | 5c626c76cc97f1d95f19c8c5e64a811ddd91bf1d600c45e03b0164d5543d8465 |
|
MD5 | 8ab350d46817ebd4617874b41ecda42c |
|
BLAKE2b-256 | 8c7e8bf4e1d887c065e86830ae53c8c7207fffe0165739dc909b187e4a2fe353 |
File details
Details for the file qtpy_led-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: qtpy_led-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.9 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 | 69bcd796d79758d1dc91f10b812529db7485d2b99c2838c952539f00ca3f7d4b |
|
MD5 | 0aa65f381f1a60b95e3a6facab72220e |
|
BLAKE2b-256 | aa19cb3c4e733984716db0df8ddd6e5d9d4e15a0fb4d04557e4b171a92230b69 |