aroberge / easygui_qt

Inspired by easygui, designed for PyQt
BSD 3-Clause "New" or "Revised" License
59 stars 18 forks source link

PyQt 5 or PySide support #20

Open thorstenkampe opened 9 years ago

thorstenkampe commented 9 years ago

Will easygui_qt eventually support PyQt5 or PySide? I already have PyQt5 on my machine so I cannot install PyQt4.

aroberge commented 9 years ago

I just added the following to all relevant files in the repository:

try:
    from PyQt4 import QtGui, QtCore
except ImportError:
    from PyQt5 import QtGui, QtCore  # untested

However, I have no idea if this will be sufficient or if the syntax has changed between PyQt5 and PyQt4 - and can not test it myself. If you could try it and report the result, it would be appreciated.

thorstenkampe commented 9 years ago

I get this on Windows:

Traceback (most recent call last):
  File "F:\PortableApps\Python3x\lib\site-packages\easygui_qt-0.9.1-py3.4.egg\easygui_qt\easygui_qt.py", line 24, in <module>
    from . import utils
  File "F:\PortableApps\Python3x\lib\site-packages\easygui_qt-0.9.1-py3.4.egg\easygui_qt\utils.py", line 125, in <module>
    class MyPageDialog(QtGui.QDialog):
AttributeError: 'module' object has no attribute 'QDialog'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:\Documents\dev\python\thorsten\cyrillic.py", line 11, in <module>
    import easygui_qt
  File "F:\PortableApps\Python3x\lib\site-packages\easygui_qt-0.9.1-py3.4.egg\easygui_qt\__init__.py", line 6, in <module>
    from .easygui_qt import *
  File "F:\PortableApps\Python3x\lib\site-packages\easygui_qt-0.9.1-py3.4.egg\easygui_qt\easygui_qt.py", line 31, in <module>
    import utils
ImportError: No module named 'utils'
aroberge commented 9 years ago

The second error puzzles me... that being said: did you import it from PyPi? I have not created a new version. I was just suggesting to try from the current repository - by cloning it.

That being said: it looks like PyQt5 has changed the modules structure (no attribute 'QDialog') which I can not test from here.

I'll keep this issue open, in case I find a way (and the time) to support both PyQt4 and PyQt5.

Sorry that I can not be more helpful at this time.

stonebig commented 9 years ago

You may look at what spider-ide folks are doing

wannaphong commented 8 years ago

QtPy ? https://github.com/goanpeca/QtPy

stonebig commented 8 years ago

(today) yes.

aroberge commented 8 years ago

I don't have any time to spend on this project at the moment; I'm open to pull requests (or feel free to fork it, of course).

uvchik commented 6 years ago

I cannot test qt4 but I forked this repository in order to adapt it to qt5 without backward compatibility with qt4.

https://github.com/uvchik/easygui_qt5

aroberge commented 6 years ago

I probably should have closed this issue : the latest version should now be compatible with qt5. (One problem: the automated tests no longer work.)

uvchik commented 6 years ago

What do mean with the latest version?

For me get_file_names() dids not work with pyqt5. I had to change it according to the following page:

http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#qfiledialog


-        files = qt_widgets.QFileDialog.getOpenFileNames(None, title, os.getcwd(),
-                                               "All Files (*.*)", options)
+        files = qt_widgets.QFileDialog.getOpenFileNames(None, title, os.getcwd(),
+                                               , "", "All Files (*.*)", options)
aroberge commented 6 years ago

By latest version, I refer to the last commit made on December 25, 2017, based on some input by a user who contacted me.

Based on what you found, obviously there is at least one bug in existing version. It is obvious that I did not test it as fully as I should have.

uvchik commented 6 years ago

I could make a PR but I am not sure if my changes work on pyqt4.

aroberge commented 6 years ago

I understand ... it would likely need and if/else statement to work reliably with both versions.

I think you are better off continuing with your fork - and I will leave this issue open as a warning for anyone interested in a qt5 compatible version. This project is at the bottom of my priority list (I started it for fun, as a means to learn qt) and I cannot give it the prompt attention it deserves.