logging.Handler not working with QThreads
Vinay Sajip
vinay_sajip at yahoo.co.uk
Fri Feb 27 18:48:39 EST 2009
On Feb 25, 11:57 pm, Lukas Hetzenecker <L... at gmx.at> wrote:
> Hello,
>
> I created a QTextEdit where I wanted to display log messages.
> A logging.Handler should do this job.
>
> It worked with one thread well, but when I start a QThread the text on all
> widgets is removed and I get many errors in my konsole:
>
> X Error: RenderBadGlyphSet (invalid GlyphSet parameter) 177
> Extension: 152 (RENDER)
> Minor opcode: 25 (RenderCompositeGlyphs32)
> Resource id: 0x0
> X Error: RenderBadGlyphSet (invalid GlyphSet parameter) 177
> Extension: 152 (RENDER)
> Minor opcode: 25 (RenderCompositeGlyphs32)
> Resource id: 0x0
> X Error: RenderBadGlyphSet (invalid GlyphSet parameter) 177
> Extension: 152 (RENDER)
> Minor opcode: 25 (RenderCompositeGlyphs32)
> Resource id: 0x0
>
> .. and so on
>
> I attatched a small example to this mail.
>
> Could anybody tell me what I'm doing wrong?
> Thanks for you help,
> Lukas
>
> logging_error.py
> 3KViewDownload
I'm not sure what exactly your problem is - I had no problem running a
slightly modified version of your script. I don't have a version of Qt
with a QPlainTextEdit, so I used a plain QTextEdit instead ('scuse the
play on words). I also modified the thread run method slightly, like
so...
def run(self):
s = self.currentThreadId()
for i in range(10):
self.log.info("Thread %s (%d)", s, i)
self.sleep(1)
With these changes (and replacing the appendPlainText with just plain
append, the script worked fine. I was able to get messages from
multiple running threads and the main window/log window into the
single QTextEdit.
My testing was conducted on Kubuntu Hardy with SIP 4.7.9 and PyQt
4.4.4. The modified script is at
http://dpaste.com/hold/2947/
Best regards,
Vinay Sajip
More information about the Python-list
mailing list