I want to use PySide to create a simple application just to output from python logging.
def mpm_print():
print 'OK'
def mpm_log():
log.info('OK')
class LabWindow(QtGui.QMainWindow):
def __init__(self):
super(LabWindow, self).__init__()
self.initUI()
mpm_print()
mpm_log()
def initUI(self):
font = QtGui.QFont()
font.setFamily("Courier")
font.setFixedPitch(True)
font.setPointSize(10)
self.qtxt = QtGui.QTextEdit(self)
self.qtxt.resize(self.size())
self.qtxt.setReadOnly(True)
self.qtxt.setFont(font)
self.resize(640, 512)
self.setWindowTitle('Efficient Algorithms Lab')
self.show()
I would like to know:
- How can I redirect stdout to write to the QTextEdit ?
- How can I write a logging.Handler to log to QTextEdit ?
Thanks
This is copy-pasted from PyQt mailing-list, but should be applicable to PySide
This should do what you want.
Example usage: