nucleic / enaml

Declarative User Interfaces for Python
http://enaml.readthedocs.io/en/latest/
Other
1.54k stars 132 forks source link

FileDialog doesn't work under PySide #29

Closed corranwebster closed 10 years ago

corranwebster commented 11 years ago

The examples/widgets/FileDialog.enaml file fails because of incompatibility between PySide and PyQt:

File "/Users/cwebster/src/enaml/enaml/qt/qt_file_dialog.py", line 30, in exec_dialog
    path, selected_filter = QFileDialog.getOpenFileNameAndFilter(
AttributeError: type object 'PySide.QtGui.QFileDialog' has no attribute 'getOpenFileNameAndFilter'

PySide only supplies getOpenFileName and related functions, without the option to return the filter as well.

corranwebster commented 11 years ago

A little more research: https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/pysideapi2.html

I'll put together a PR to smooth over the difference.

sccolbert commented 11 years ago

Yep, I expected this. Feel free to do a PR.

sccolbert commented 11 years ago

Closing as a PySide issue. Can revisit when a PR is ready.

WarrenWeckesser commented 11 years ago

Hey @corranwebster, is a PR to handle this still somewhere on your to-do list?

corranwebster commented 11 years ago

Not in the near-term - project-based UI work I'm doing it currently mainly in TraitsUI for reasons outside my control.

In the medium term I may get back to Enaml, and then this may be more of an issue for me/Enthought.

jwiggins commented 10 years ago

@sccolbert: The way this was fixed in enaml 0.6.8 was with the following code:

if qt_api == 'pyqt':
    _NATIVE_METHOD_NAMES = {
        'open_file': 'getOpenFileNameAndFilter',
        'open_files': 'getOpenFileNamesAndFilter',
        'save_file': 'getSaveFileNameAndFilter',
        'directory': 'getExistingDirectory',
    }
else:
    _NATIVE_METHOD_NAMES = {
        'open_file': 'getOpenFileName',
        'open_files': 'getOpenFileNames',
        'save_file': 'getSaveFileName',
        'directory': 'getExistingDirectory',
    }

...

method = getattr(QFileDialog, _NATIVE_METHOD_NAMES[mode])
method(...)

Do you have any problem with this being resolved in the same way now?