[PyQt] logger outputs duplicate messages in the console window

DDGG ddcatgg at gmail.com
Tue Dec 18 19:09:55 GMT 2007


Hello friends!
I found my logger outputs duplicate messages in the console window, i
found it looks like is the uic module causes.

# test.py

import sys
import logging
from PyQt4 import QtGui, uic

app = QtGui.QApplication(sys.argv)

logger = logging.getLogger("begginer")
handler = logging.StreamHandler()
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)

window = QtGui.QWidget()
uifile = "window.ui"
uic.loadUi(uifile, window)

logger.debug("hello")

window.show()
app.exec_()

# end of test.py

The window.ui file can be very simple, just like this:
<ui version="4.0" >
 <class>Form</class>
 <widget class="QWidget" name="Form" >
 </widget>
 <resources/>
 <connections/>
</ui>

When it runs, console window outputs:
hello
DEBUG:begginer:hello

How to avoid the 2nd debug message?
Thanks!


More information about the PyQt mailing list