In the recent past I've used PyQt to show an Open Dialog from Jupyter, like
so:
from PyQt4 import QtGui
app = QtGui.QApplication([dir])
fname = QtGui.QFileDialog.getOpenFileName(None, "Select a file...", '.',
filter="All files (*)")
This seems to work okay. On a new installation, I'm trying the equivalent
with PyQt5:
from PyQt5.QtWidgets import QApplication, QFileDialog
app = QApplication.instance()
if not app:
app = QApplication([dir])
fname = QFileDialog.getOpenFileName(None, "Select a file...", '.', filter="All
files (*)")
print(str(fname))
This version also works okay, except if the user clicks the dialog's
*Cancel* button! The print statement executes but the dialog hangs and the
process needs to be force quit.
May or may not be relevant, but oddly the fname return value is not the
filename as the documentation suggests
<http://pyqt.sourceforge.net/Docs/PyQt4/qfiledialog.html#getOpenFileName>.
Instead is a tuple of the filename and filter string, as if
QFileDialog.getOpenFileNameAndFilter had been called instead.
Unfortunately I can't just install PyQt4 due to a conflict (assumedly
because I installed the Python3 version of Anaconda:
UnsatisfiableError: The following specifications were found to be in
conflict:
- pyqt 4* -> python 2.6* -> openssl 1.0.1*
- python 3.6*
Any ideas why the QFileDialog is hanging on cancel? Any suggestions for a
workaround?
This is all on macOS, but I'm looking for a cross-platform solution.
Regards,
Heath
--
You received this message because you are subscribed to the Google Groups
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jupyter/470d3376-179a-4dc5-89bb-64f4765afb10%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.