[PyQt] A dire warning message

Algis Kabaila akabaila at pcug.org.au
Thu Jul 7 10:22:34 BST 2011


This bothersome warning message probably has nothing to do with PyQt.  
However, it does occur whenever I use PyQt.  No great harm seems to occur and 
the programs function normally, except for that message.  Is there something 
wrong with my setup or should I just forget all about it?

I attach a little test program "open.py". It does not do anything - and just 
tries to open a  file dialog after a click on the pushButton.  That produces 
the error message.

The "program" is mainly filled with the message itself and some comments. I 
would think that this probably has been dealt with, but I will not know if I 
do not ask... so thanks again for your patience.  OTH, may be other people 
will find this informative, too - or am the only one being subjected to this 
warning?

#!/usr/bin/env python3.2
''' 
open.py - a sample program to show the dire warning it generates
and every other program that tries to use a file read dialog.
Platform - kubuntu 11.04 "natty"
Python 3.2
Qt 4.7.2 (from "natty" binaries.
PyQt4 4.8.4 - bound to Python 3.2 whilst compiling

On opening a file dialog, I get this warning:

KGlobal::locale::Warning your global KLocale is being recreated with
a valid main component instead of a fake component, this usually means
you tried to call i18n related functions before your main component 
was created. You should not do that since it most likely will not work 

Search on the net seems to give some grim news:

<quote start>
Re: VLC Hangs on Open File dialog
Postby Rémi Denis-Courmont » Sat Jan 29, 2011 11:58 pm 
In the mean time, someone in KDE actually looked at the issue. 
It turns to be a longstanding known bug in the QProcess class from Qt4. 
That bug gets triggered by a new "feature" in KDE 4.6 relative to MIME
types in the Open and Save dialogs, that happens to involve the 
QProcess class.

In the end, VLC is blaming KDE, KDE is blaming Qt, and Qt is blaming the 
kernel.
<quote end>
'''
import sys

from PyQt4.QtGui  import QDialog, QFileDialog, QApplication

from ui_open import Ui_Dialog

class Dialog(QDialog, Ui_Dialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.pushButton.clicked.connect(self.open)
        
    def open(self):
        fname = QFileDialog.getOpenFileName(self,
                        "Open File", '.', "Files (*.*)")
# The following warning message is generated:                         
# KGlobal::locale::Warning your global KLocale is being recreated with 
# a valid main component instead of a fake component, this usually 
# means you tried to call i18n related functions before your main 
# component was created. You should not do that since it most likely
# will not work 
    
if __name__ == '__main__':
    app = QApplication(sys.argv)
    frame = Dialog()
    frame.show()
    app.exec_()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: open.ui
Type: application/x-designer
Size: 1050 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110707/d9d9adf6/attachment-0001.bin>


More information about the PyQt mailing list