A QT signal/slot concept for Python with Weakrefs.
Project description
QSignal – A QT Signal/slot for python
This project provides easy to use Signal class for implementing Signal/Slot mechanism in Python. It does not implement it strictly but rather creates the easy and simple alternative.
Classes
Signal
qsignal.Signal is the main class.
To create a signal, just make a sig = qsignal.Signal and set up an emitter of it. Or create it with sig = qsignal.Signal(emitter=foo).
To emit it, just call your sig(). Or emit it in asynchronous mode with the method async.
Example:
>>> from qsignal import Signal
>>> # Creating signal >>> sig = Signal()
>>> # Or >>> myobject.signal = Signal(emitter=myobject)
>>> # Connecting to signals >>> sig.connect(callback) >>> myobject.signal.connect(sig) >>> myobject.signal.connect(otherobject.callback_method)
>>> # Emitting >>> sig() >>> myobject.signal('argument(s)', optional=True)
>>> # Emitting in asynchronous mode >>> sig.async()
To connect slots to it, pass callbacks into connect. The connections are maintained through weakref, thus you don’t need to search for them and disconnect whenever you’re up to destroy some object.
Signaller
The base class for objects to maintain their Signals.
The only purpose of this class is to automate Signal names and emitter references.
>>> from qsignal import Signal, Signaller
>>> # For example, this is a class... >>> class MyClass(Signaller): >>> my_signal = Signal()
>>> # This is a slot... >>> def my_slot(): >>> sig = Signal.emitted() >>> assert sig.name == my_signal >>> assert sig.emitter.__class__ == MyClass
>>> # And the connections... >>> o = MyClass() >>> o.my_signal.connect(my_slot) >>> #... >>> o.my_signal()
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
Built Distribution
File details
Details for the file qsignal-1.0.2b1.tar.gz
.
File metadata
- Download URL: qsignal-1.0.2b1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 603607c0a1ef0b050a5b8806793c1b203c74d34da9815fe87b17a7bf30f8c1ce |
|
MD5 | a749546330b4da579a18f0fa6fa86d33 |
|
BLAKE2b-256 | 25f6876034a74406da8b5d40a30e8a9afefd4ceb050bda691e5c4016b4428dac |
File details
Details for the file qsignal-1.0.2b1-py2.py3-none-any.whl
.
File metadata
- Download URL: qsignal-1.0.2b1-py2.py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12f758d84e543bfc209fba81365a2777039a457d25427253996b0fb83d14ee1c |
|
MD5 | 2a5fba356eb42d102b13290a0116ccea |
|
BLAKE2b-256 | bc7aa17c3e2517a52c9fb76dd3239a12c5f03f32052efb040acbb324f0c6a178 |