How to Redirect Logger Output into PyQt Text Widget

后端 未结 2 810
盖世英雄少女心
盖世英雄少女心 2020-12-25 08:44

A code posted on Redirecting Output in PyQt does two good things at once: it takes advantage of logging module to nicely format messages and it redirects standa

2条回答
  •  时光说笑
    2020-12-25 09:10

    The answer given by dano works for 2.7.x, but not for 3.x.

    To get the code provided by @dano working in 3.4.3 I had to make the obvious changes to the print statements and also change the write() method in the XStream class from self.messageWritten.emit(unicode(msg)) to self.messageWritten.emit(msg). That unicode call just made the dialog sit there and stare back at me in amusement.

提交回复
热议问题