AttriBox - Python Descriptors the Easy Way
Installation
Install AttriBox easily with pip:
pip install attribox
Quick Start
Imagine having nested custom classes with a requirement of descriptor protocol implementation. The AI advices you to rethink the design, before they present you with hundreds of lines of syntactic broccoli. Meanwhile, your friends are asking you what you are doing with your life. Well, the AttriBox is here to help!
class SomeGraphics:
"""Imagine you wish to encapsulate a graphical problem in a class. You
already have custom classes for the components, but now you wish you
had implemented them as descriptors, but of course descriptors are
unique to the class and not to the instance. The memories are coming.
With them tears begin to form. Never fear! AttriBox is here!"""
fillColor = AttriBox[RGB](144, 255, 0)
borderColor = AttriBox[RGB](0, 0, 0)
centeredDiv = AttriBox[GetRect](69, 420)
The above code implements the class attributes as descriptors. The
AttriBox holds on to the class for you, until one of your instances
invokes __get__ at which point AttriBox creates a dedicated specimen for
just your instance.
A More Ambitious Example
Suppose you are designing a graphical user interface. You wish to use the descriptor protocol to expose the I/O communication directly to the user interface. You see all of those wonderful numbers over there on the robot or whatever, and you see those tempting 'set' methods on your descriptors.
class MainApp(QMainWindow):
"""The basic application window."""
mainMenuBar = AttriBox[MenuBar](this) # yes, 'this' is a thing
mainStatusBar = AttriBox[StatusBar](this) # fr
baseLayout = AttriBox[Grid]()
baseWidget = AttriBox[QWidget]()
indicator = AttriBox[Indicator]()
button = AttriBox[Button]()
slider = AttriBox[Slider]()
def initUi(self) -> None:
"""Initializes the user interface."""
self.baseLayout.addWidget(self.indicator, 0, 0)
self.baseLayout.addWidget(self.button, 1, 0)
self.baseLayout.addWidget(self.slider, 2, 0)
self.baseWidget.setLayout(self.baseLayout)
self.setCentralWidget(self.baseWidget)
self.setMenuBar(self.mainMenuBar)
self.setStatusBar(self.mainStatusBar)
def connectSignals(self) -> None:
"""Connects the signals to the slots."""
self.button.clicked.connect(self.indicator.toggle)
self.slider.valueChanged.connect(self.indicator.setValue)
self.slider.valueChanged.connect(self.mainStatusBar.setValue)
Metadata
Release files for attribox 0.1.33
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attribox-0.1.33.tar.gz | 21.9 kB | Without provenance | Details for attribox-0.1.33.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attribox-0.1.33-py3-none-any.whl | Python 3 | none | any | Details for attribox-0.1.33-py3-none-any.whl |
Total release size: 46.8 kB
Release files / attribox-0.1.33.tar.gz
| Download URL | attribox-0.1.33.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3cbbcd26dae450faddc5fda7038b829832bf67d57226a45c81f2086c9264ae4d
|
|
BLAKE2b-256 checksum How to use checksums |
5be307fbc5c4cef8ffda8a0826d71ecb226e4d3d59153bc0f41622e3d087d720
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / attribox-0.1.33-py3-none-any.whl
| Download URL | attribox-0.1.33-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdd49577cb9afc8c2f1efc6063ded0fc7a648d34bd334e966c6034a601e87390
|
|
BLAKE2b-256 checksum How to use checksums |
95db3cc367eba1ea8540db3411429545dd2a241617fc36581b30c1f50c304c1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for attribox 0.1.33
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.