From 8f58e0d1d3f813e26c2bf41bdc17e5b92af635c5 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 30 Aug 2016 08:23:10 +0000 Subject: [PATCH 1/5] Update documentation for load_ui --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3b9d8604..607a5b5d 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ All members of `Qt` stem directly from those available via PySide2, along with t | `__qt_version__` | `str` | Reference to version of Qt, such as Qt 5.6.1 | `__binding_version__` | `str` | Reference to version of binding, such as PySide 1.2.6 | `__wrapper_version__` | `str` | Version of this project -| `load_ui()` | `func` | Minimal wrapper of PyQt4.loadUi and PySide equivalent +| `load_ui(fname=str)` | `func` | Minimal wrapper of PyQt4.loadUi and PySide equivalent
@@ -136,12 +136,12 @@ import sys import Qt app = QtWidgets.QApplication(sys.argv) -ui = Qt.load_ui("my.ui") +ui = Qt.load_ui(fname="my.ui") ui.show() app.exec_() ``` -Please note, for maximum compatibility, only pass the argument of the filename to the `load_ui` function. +Please note, `load_ui` has only one argument, whereas the PyQt and PySide equivalent has more. See [here](https://github.com/mottosso/Qt.py/pull/81) for details - in a nutshell, those arguments differ between PyQt and PySide in incompatible ways.
From 431d3ecc425a1ccdda8fbd4119081438234fd16d Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 30 Aug 2016 08:27:59 +0000 Subject: [PATCH 2/5] Clarify documentation and return values --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 607a5b5d..d60244d6 100644 --- a/README.md +++ b/README.md @@ -79,13 +79,13 @@ app.exec_() All members of `Qt` stem directly from those available via PySide2, along with these additional members. -| Attribute | Type | Value -|:------------------------|:-------|:------------ -| `__binding__` | `str` | A string reference to binding currently in use -| `__qt_version__` | `str` | Reference to version of Qt, such as Qt 5.6.1 -| `__binding_version__` | `str` | Reference to version of binding, such as PySide 1.2.6 -| `__wrapper_version__` | `str` | Version of this project -| `load_ui(fname=str)` | `func` | Minimal wrapper of PyQt4.loadUi and PySide equivalent +| Attribute | Returns | Description +|:------------------------|:----------|:------------ +| `__binding__` | `str` | A string reference to binding currently in use +| `__qt_version__` | `str` | Reference to version of Qt, such as Qt 5.6.1 +| `__binding_version__` | `str` | Reference to version of binding, such as PySide 1.2.6 +| `__wrapper_version__` | `str` | Version of this project +| `load_ui(fname=str)` | `QObject` | Minimal wrapper of PyQt4.loadUi and PySide equivalent
From c41007a3a830962dee9a10ddd03712d409b32c77 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 30 Aug 2016 08:44:53 +0000 Subject: [PATCH 3/5] Test that documentation for load_ui is true --- tests.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests.py b/tests.py index 5aa45a1d..9cc59f98 100644 --- a/tests.py +++ b/tests.py @@ -6,6 +6,7 @@ """ import os +import io import sys import imp import shutil @@ -24,6 +25,36 @@ def setup(): self.tempdir = tempfile.mkdtemp() + self.ui_qwidget = os.path.join(self.tempdir, "qwidget.ui") + + with io.open(self.ui_qwidget, "w", encoding="utf-8") as f: + f.write(u"""\ + + + Form + + + + 0 + 0 + 235 + 149 + + + + Form + + + + + + + + + + +""" +) def teardown(): @@ -143,6 +174,13 @@ def test_sip_api_qtpy(): % sip.getapi("QString")) +def test_load_ui_returntype(): + """load_ui returns an instance of QObject""" + from Qt import QtCore, load_ui + obj = load_ui(self.ui_qwidget) + assert isinstance(obj, QtCore.QObject) + + def test_vendoring(): """Qt.py may be bundled along with another library/project From 95fcc343b91a3424acf06ff6b6d6df6251656823 Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 30 Aug 2016 08:47:29 +0000 Subject: [PATCH 4/5] Test every binding; TODO: improve maintenance of these kinds of tests --- tests.py | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tests.py b/tests.py index 9cc59f98..0bb0ed16 100644 --- a/tests.py +++ b/tests.py @@ -174,11 +174,40 @@ def test_sip_api_qtpy(): % sip.getapi("QString")) -def test_load_ui_returntype(): - """load_ui returns an instance of QObject""" - from Qt import QtCore, load_ui - obj = load_ui(self.ui_qwidget) - assert isinstance(obj, QtCore.QObject) +def test_pyside_load_ui_returntype(): + """load_ui returns an instance of QObject with PySide""" + + with pyside(): + from Qt import QtCore, load_ui + obj = load_ui(self.ui_qwidget) + assert isinstance(obj, QtCore.QObject) + + +def test_pyqt4_load_ui_returntype(): + """load_ui returns an instance of QObject with PyQt4""" + + with pyqt4(): + from Qt import QtCore, load_ui + obj = load_ui(self.ui_qwidget) + assert isinstance(obj, QtCore.QObject) + + +def test_pyside2_load_ui_returntype(): + """load_ui returns an instance of QObject with PySide2""" + + with pyside2(): + from Qt import QtCore, load_ui + obj = load_ui(self.ui_qwidget) + assert isinstance(obj, QtCore.QObject) + + +def test_pyqt5_load_ui_returntype(): + """load_ui returns an instance of QObject with PyQt5""" + + with pyqt5(): + from Qt import QtCore, load_ui + obj = load_ui(self.ui_qwidget) + assert isinstance(obj, QtCore.QObject) def test_vendoring(): From 46914510db9d480b99b6137166da6d7cca18376c Mon Sep 17 00:00:00 2001 From: Marcus Ottosson Date: Tue, 30 Aug 2016 08:59:05 +0000 Subject: [PATCH 5/5] Fix tests.py --- tests.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests.py b/tests.py index 0bb0ed16..7903e2f4 100644 --- a/tests.py +++ b/tests.py @@ -178,7 +178,9 @@ def test_pyside_load_ui_returntype(): """load_ui returns an instance of QObject with PySide""" with pyside(): - from Qt import QtCore, load_ui + import sys + from Qt import QtWidgets, QtCore, load_ui + app = QtWidgets.QApplication(sys.argv) obj = load_ui(self.ui_qwidget) assert isinstance(obj, QtCore.QObject) @@ -187,7 +189,9 @@ def test_pyqt4_load_ui_returntype(): """load_ui returns an instance of QObject with PyQt4""" with pyqt4(): - from Qt import QtCore, load_ui + import sys + from Qt import QtWidgets, QtCore, load_ui + app = QtWidgets.QApplication(sys.argv) obj = load_ui(self.ui_qwidget) assert isinstance(obj, QtCore.QObject) @@ -196,7 +200,9 @@ def test_pyside2_load_ui_returntype(): """load_ui returns an instance of QObject with PySide2""" with pyside2(): - from Qt import QtCore, load_ui + import sys + from Qt import QtWidgets, QtCore, load_ui + app = QtWidgets.QApplication(sys.argv) obj = load_ui(self.ui_qwidget) assert isinstance(obj, QtCore.QObject) @@ -205,7 +211,9 @@ def test_pyqt5_load_ui_returntype(): """load_ui returns an instance of QObject with PyQt5""" with pyqt5(): - from Qt import QtCore, load_ui + import sys + from Qt import QtWidgets, QtCore, load_ui + app = QtWidgets.QApplication(sys.argv) obj = load_ui(self.ui_qwidget) assert isinstance(obj, QtCore.QObject)