Redraw widgets on request. Add scrollbar demo.
class Signal:
"""Simple implementation of signal/slot concept.
In signalling class, add attribute with "sig_" prefix:
self.sig_clicked = Signal()
In listening class, add normal method, e.g. "close()" and connect it, e.g:
button.sig_clicked.connect(window.close)
When button gets clicked, it should call the signal:
self.sig_clicked()
Then window.close() will be called.
"""
def __init__(self, allow_stop=False):
self._handlers = []
#: Allow one of the handlers to stop processing signal
#: The handler should return True value,
#: then other handlers will not be called
self.allow_stop = allow_stop
def __call__(self, *args, **kwargs):
"""Emit the signal to all connected handlers."""
for handler in self._handlers:
res = handler(*args, **kwargs)
if self.allow_stop and res:
return True
def connect(self, handler):
if not handler in self._handlers:
self._handlers.append(handler)
def disconnect(self, handler):
self._handlers.remove(handler)