Created
May 29, 2013 19:31
-
-
Save chiiph/5673107 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
from functools import partial | |
from PySide import QtCore, QtGui | |
class Obj(QtCore.QObject, logging.Handler): | |
sig = QtCore.Signal(dict) | |
def __init__(self): | |
QtCore.QObject.__init__(self) | |
logging.Handler.__init__(self) | |
def emit(self, logRecord): | |
# This is intended to be logging.Handler | |
# implementation of emit, not the QObject one | |
self.sig.emit({"a":123, "b":321}) | |
if __name__ == "__main__": | |
app = QtGui.QApplication(sys.argv) | |
handler = Obj() | |
logger = logging.getLogger(name='test') | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(handler) | |
w = QtGui.QWidget() | |
b = QtGui.QPushButton(w) | |
b.clicked.connect(partial(logger.debug, "ASD")) | |
w.show() | |
app.exec_() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment