[PyQt] A dire warning message

Algis Kabaila akabaila at pcug.org.au
Sat Jul 9 02:29:24 BST 2011

On Fri, 8 Jul 2011 11:52:17 PM Baz Walter wrote:
> but to users it can look like a bug if they are running a non-kde app.
> i re-installed the libkde.so plugin and ran this pure pyqt test script:
> ######
> import sys
> from PyQt4.QtGui import QApplication, QFileDialog, QPushButton
> class Window(QPushButton):
>      def __init__(self):
>          QPushButton.__init__(self, 'Open')
>          self.clicked.connect(self.open)
>      def open(self):
>          dialog = QFileDialog(self, "Open File", '.', "Files (*.*)")
>          dialog.exec_()
> if __name__ == '__main__':
>      app = QApplication(sys.argv)
>      win = Window()
>      win.show()
>      sys.exit(app.exec_())
> ######
> sure enough, when i click the button, a *kde* file dialog appears and i
> see the "dire warning".
> however, when i set the following option:
>      dialog.setOption(QFileDialog.DontUseNativeDialog)
> a *qt* file dialog appears and there is no "dire warning".
> this using pyqt 4.8.4, qt 4.7.3, and kde-4.8.5 on archlinux.
> (as a further note: with non-kde apps, the kde file dialog can be
> annoyingly slow to open compared with the qt one - which is another
> reason why i prefer to remove this plugin on my system).
> _______________________________________________


Looks like the "magic line" 
is the solution - congratulations to you, Baz!

I verified your solution on my kubuntu 11.04 "natty" 
The record of CLI commands and results are:
with try1.py Baz's program without the "magic line" '
and try2.py with the "magic line". 

First, with libkde.so in place: 
ak at supremo:/dat/work/py3/Baz$ python3 try1.py
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 
ak at supremo:/dat/work/py3/Baz$ python3 try2.py

With libkde.so removed (no reboot!):
ak at supremo:/dat/work/py3/Baz$ python3 try1.py
ak at supremo:/dat/work/py3/Baz$ python3 try2.py
ak at supremo:/dat/work/py3/Baz$

On your example your suggestion works on natty and python3.2 [SOLVED!] 

Now why the removal of the libkde.so did not eliminate the problem on my 
script? Most likely I stuffed something up- will look into it (basically repeat 
my experiment).

Congratulations and thanks to Baz!


More information about the PyQt mailing list