View Single Post
Old 07-08-2014, 08:42 AM   #9
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
What is the best way to deal with the change to the QFileDialog.getOpenFileName method?

PyQt4 used to return a single filepath but PyQt5 returns 2 strings (filepath, filter). I don't need the filter part of the result so I've temporarily solved it like this:
Code:
fd = QFileDialog()
if hasattr(fd, 'getOpenFileNameAndFilter'):
    # PyQt4
    ans = fd.getOpenFileNameAndFilter(self, mycaption, mydir, myfilter)
else:    
    # PyQt5
    ans = fd.getOpenFileName(self, mycaption, mydir, myfilter)
selfile = unicode(ans[0])
Is there a better calibre-way of doing this? I fully admit that this particular personal plugin started life completely external to calibre so uses less calibre special functionality than it might. I tend to only fix things if they break.

I have quite a few other questions (mainly to do with SIGNAL) but ... one thing at a time.
jackie_w is offline   Reply With Quote