Browse Source

Changed QT binding to PySide2, version 0.3.0

Alfio Puglisi 1 year ago
parent
commit
1447fea3ca

+ 2 - 2
docs/conf.py

@@ -24,7 +24,7 @@ author = 'Alfio Timothy Puglisi'
 
 # -- General configuration ---------------------------------------------------
 
-# Mock the PyQt5 module
+# Mock the PySide2 module
 # Otherwise the build on readthedocs.io fails!
 
 class QtWidgets:
@@ -45,7 +45,7 @@ class QtWidgets:
             return 1    # With this, the main file will not trty
                         # to create a new one.
 
-sys.modules['PyQt5.QtWidgets'] = QtWidgets
+sys.modules['PySide2.QtWidgets'] = QtWidgets
 
 sys.path.insert(0, os.path.abspath('..'))
 from guietta.__version__ import __version__

+ 11 - 1
docs/index.rst

@@ -17,12 +17,22 @@ Guietta is a tool that makes simple GUIs *simple*::
     gui.run()
 
 
-And here is what appears::
+And here is what appears:
 
 .. image:: example.png
 
 
+Installation
+============
 
+ **pip install guietta**
+ 
+
+If you use conda, please read our page on
+`QT incompatibilities with conda <qt_conda.html>`_.
+
+Documentation
+=============
 
 .. toctree::
    :maxdepth: 1

+ 23 - 0
docs/qt_conda.rst

@@ -0,0 +1,23 @@
+
+QT incompatibilities with conda
+===============================
+
+There have been reports of problems using PyQt5 in a conda environment,
+for example:
+
+ - https://github.com/ContinuumIO/anaconda-issues/issues/1970
+ - https://github.com/ContinuumIO/anaconda-issues/issues/1554
+ 
+It appears that the root cause is conda's renaming of "PyQt5" to "pyqt".
+This leads pip to believe that PyQt5 is not installed, so it installs it,
+resulting in two incompatible libraries and a crash at the first
+"import PyQt5".
+
+Guietta uses the `PySide2 Qt binding <https://pypi.org/project/PySide2/>`_,
+so it should work around this problem, nevertheless we recommend caution
+whe installing Guietta under conda. A good practice would be to make sure
+that PySide2 is installed first:
+
+ conda install PySide2
+ 
+This way pip should detect it and avoid trying to install the pip version.

+ 1 - 1
docs/requirements.txt

@@ -1,3 +1,3 @@
 sphinx>=1.7.5
-PyQt5
+PySide2
 

+ 1 - 1
docs/tutorial.rst

@@ -12,7 +12,7 @@ Install Guietta
 
 ``pip install guietta``
 
-This should also automatically install PyQt5, if you don't already have it.
+This should also automatically install PySide2, if you don't already have it.
 If you plan to use Matplotlib together with guietta, you should install that
 too. It is not done automatically.
 

+ 1 - 1
guietta/__version__.py

@@ -1,3 +1,3 @@
-VERSION = (0, 2, 3)
+VERSION = (0, 3, 0)
 
 __version__ = '.'.join(map(str, VERSION))

+ 1 - 1
guietta/examples/listbox.py

@@ -27,7 +27,7 @@ gui.events(
     [     test   ],
    )
 
-from PyQt5.QtWidgets import  QAbstractItemView
+from PySide2.QtWidgets import  QAbstractItemView
 gui.widgets['listbox'].setSelectionMode(QAbstractItemView.ExtendedSelection)
 
 gui.listbox = ['a', 'b', 'c', 'd']

+ 2 - 2
guietta/examples/slider.py

@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 
 from guietta import B, E, _, Gui, Quit
-from PyQt5.QtWidgets import QSlider
-from PyQt5.QtCore import Qt
+from PySide2.QtWidgets import QSlider
+from PySide2.QtCore import Qt
 
 def do_eval(gui, *args):
     gui.result = eval(gui.expr)

+ 1 - 1
guietta/examples/valueslider.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from PyQt5.QtCore import Qt
+from PySide2.QtCore import Qt
 from guietta import Gui, _, ___, III, HValueSlider, VValueSlider
 
 def do_slider(gui, value):

+ 9 - 9
guietta/guietta.py

@@ -49,13 +49,13 @@ from types import SimpleNamespace
 from collections import namedtuple, defaultdict
 from collections.abc import Sequence, Mapping, MutableSequence
 
-from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QAbstractSlider
-from PyQt5.QtWidgets import QPushButton, QRadioButton, QCheckBox, QFrame
-from PyQt5.QtWidgets import QLineEdit, QGridLayout, QSlider, QAbstractButton
-from PyQt5.QtWidgets import QMessageBox, QListWidget, QAbstractItemView
-from PyQt5.QtWidgets import QPlainTextEdit, QHBoxLayout
-from PyQt5.QtGui import QPixmap, QIcon
-from PyQt5.QtCore import Qt, QTimer, pyqtSignal, QEvent
+from PySide2.QtWidgets import QApplication, QLabel, QWidget, QAbstractSlider
+from PySide2.QtWidgets import QPushButton, QRadioButton, QCheckBox, QFrame
+from PySide2.QtWidgets import QLineEdit, QGridLayout, QSlider, QAbstractButton
+from PySide2.QtWidgets import QMessageBox, QListWidget, QAbstractItemView
+from PySide2.QtWidgets import QPlainTextEdit, QHBoxLayout
+from PySide2.QtGui import QPixmap, QIcon
+from PySide2.QtCore import Qt, QTimer, Signal, QEvent
 
 # We need a QApplication before creating any widgets
 if QApplication.instance() is None:
@@ -334,7 +334,7 @@ VSeparator = _Separator(QFrame.VLine)
 class QListWidgetWithDropSignal(QListWidget):
     '''A QListWidget that emits a signal when something is dropped on it.'''
 
-    dropped = pyqtSignal()
+    dropped = Signal()
 
     def dropEvent(self, event):
         super().dropEvent(event)
@@ -598,7 +598,7 @@ def M(name, width=5, height=3, dpi=100):
 class StdoutLog(QPlainTextEdit):
     '''Log widget showing the stdout/stderr in the GUI'''
 
-    newData = pyqtSignal(str)
+    newData = Signal(str)
 
     def __init__(self):
         super().__init__('')

+ 1 - 1
requirements.txt

@@ -1 +1 @@
-PyQt5
+PySide2

+ 3 - 8
setup.py

@@ -13,8 +13,8 @@ AUTHOR = 'Alfio Puglisi'
 LICENSE = 'MIT'
 #KEYWORDS = 
 
-here = os.path.abspath(os.path.dirname(__file__))
 # Load the package's __version__.py module as a dictionary.
+here = os.path.abspath(os.path.dirname(__file__))
 about = {}
 with open(os.path.join(here, NAME, '__version__.py')) as f:
     exec(f.read(), about)
@@ -56,11 +56,6 @@ class UploadCommand(Command):
 
         sys.exit()
 
-# If you use Anaconda, installing PyQt5 with pip breaks
-# the one shipped with Anaconda, (segfault when importing
-# because of difference in the binary libraries),
-# and there is no easy fix. So we don't put it in the requirements.
-
 
 setup(name=NAME,
       description=DESCRIPTION,
@@ -78,7 +73,7 @@ setup(name=NAME,
       packages=['guietta',
                 'guietta.examples',
                 ],
-      install_requires= [],
+      install_requires=['PySide2'],
       test_suite='test',
-      cmdclass={'upload': UploadCommand, },
+      cmdclass={'upload': UploadCommand},
       )

+ 1 - 1
test/collapse_names_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _collapse_names
 
-from PyQt5.QtWidgets import QWidget
+from PySide2.QtWidgets import QWidget
 
 '''((widget, name1), name2) -> (widget, name2), arbitrarily nested'''
 

+ 1 - 1
test/compacts_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _convert_compacts, L, B
 
-from PyQt5.QtWidgets import QWidget, QLineEdit
+from PySide2.QtWidgets import QWidget, QLineEdit
 
 '''
     Converts:

+ 1 - 1
test/helper_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _sequence, _mutable_sequence
 
-from PyQt5.QtWidgets import QWidget 
+from PySide2.QtWidgets import QWidget 
 
 class HelperTest(unittest.TestCase):
     

+ 1 - 1
test/init_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import Gui, _
 
-from PyQt5.QtWidgets import QWidget
+from PySide2.QtWidgets import QWidget
 
 
 class InitTest(unittest.TestCase):

+ 1 - 1
test/layer_check_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _layer_check
 
-from PyQt5.QtWidgets import QWidget
+from PySide2.QtWidgets import QWidget
 
 
 class LayerCheckTest(unittest.TestCase):

+ 1 - 1
test/process_slots_test.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _process_slots, _specials
 
-from PyQt5.QtWidgets import QWidget
+from PySide2.QtWidgets import QWidget
 
 '''
     A callable is transformed into ('default', callable). The callable

+ 1 - 1
test/test_check_string.py

@@ -3,7 +3,7 @@
 import unittest
 from guietta.guietta import _check_string, _specials
 
-from PyQt5.QtWidgets import QWidget
+from PySide2.QtWidgets import QWidget
 
 
 class CheckStringTestTest(unittest.TestCase):