diff --git a/sept_qt/documentation_widget.py b/sept_qt/documentation_widget.py index f708846..be6c5a2 100644 --- a/sept_qt/documentation_widget.py +++ b/sept_qt/documentation_widget.py @@ -1,7 +1,17 @@ -from PySide import QtGui, QtWebKit +from Qt import QtGui, QtWidgets +import Qt +if Qt.__binding__ == "PySide2": + from PySide2 import QtWebkitWidgets -class DocumentationWidget(QtGui.QTabWidget): + QWebView = QtWebkitWidgets.QWebView +elif Qt.__binding__ == "PySide": + from PySide import QtWebKit + + QWebView = QtWebKit.QWebView + + +class DocumentationWidget(QtWidgets.QTabWidget): """ DocumentationWidget is designed to give a fast and easy way to display the Token and Operator documentation to your users. @@ -21,13 +31,13 @@ def __init__(self, parser, parent=None): documentation from. :param sept.PathTemplateParser parser: Parser object driving the docs. - :param QtGui.QWidget|None parent: Optional Qt parent widget. + :param QtWidgets.QWidget|None parent: Optional Qt parent widget. """ super(DocumentationWidget, self).__init__(parent) self.parser = parser - self._token_webview = QtWebKit.QWebView() - self._operator_webview = QtWebKit.QWebView() + self._token_webview = QWebView() + self._operator_webview = QWebView() self.addTab(self._token_webview, "Tokens") self.addTab(self._operator_webview, "Operators") diff --git a/sept_qt/input_widget.py b/sept_qt/input_widget.py index 9476e4f..d5cf03e 100644 --- a/sept_qt/input_widget.py +++ b/sept_qt/input_widget.py @@ -1,9 +1,9 @@ from sept import errors -from PySide import QtGui, QtCore +from Qt import QtGui, QtWidgets, QtCore -class TemplateInputWidget(QtGui.QWidget): +class TemplateInputWidget(QtWidgets.QWidget): """ TemplateInputWidget can be used to interactively create `sept.Template` objects and check their validity. @@ -50,7 +50,7 @@ def __init__(self, parser, error_colour=None, timeout=None, parent=None): the error highlighting. :param int|None timeout: Optional timeout in ms that will be waited before displaying an error. - :param QtGui.QWidget|None parent: Optional Qt parent widget. + :param QtWidgets.QWidget|None parent: Optional Qt parent widget. """ super(TemplateInputWidget, self).__init__(parent) self.parser = parser @@ -64,20 +64,20 @@ def __init__(self, parser, error_colour=None, timeout=None, parent=None): self._build_ui() def _build_ui(self): - self.setLayout(QtGui.QVBoxLayout()) + self.setLayout(QtWidgets.QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) - self._line_widget = QtGui.QTextEdit(self) - self._line_widget.setLineWrapMode(QtGui.QTextEdit.NoWrap) + self._line_widget = QtWidgets.QTextEdit(self) + self._line_widget.setLineWrapMode(QtWidgets.QTextEdit.NoWrap) self._line_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self._line_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self._line_widget.setFixedHeight(23) self._line_widget.setMinimumWidth(365) self._line_widget.setSizePolicy( - QtGui.QSizePolicy.Policy.Expanding, - QtGui.QSizePolicy.Policy.Fixed, + QtWidgets.QSizePolicy.Policy.Expanding, + QtWidgets.QSizePolicy.Policy.Fixed, ) - self._error_widget = QtGui.QLabel(self) + self._error_widget = QtWidgets.QLabel(self) self._error_widget.setWordWrap(True) self._error_widget.hide() diff --git a/sept_qt/preview_widget.py b/sept_qt/preview_widget.py index 0f4e51d..362a854 100644 --- a/sept_qt/preview_widget.py +++ b/sept_qt/preview_widget.py @@ -1,9 +1,9 @@ from sept import errors -from PySide import QtGui, QtCore +from Qt import QtWidgets, QtCore -class TemplatePreviewWidget(QtGui.QPlainTextEdit): +class TemplatePreviewWidget(QtWidgets.QPlainTextEdit): """ TemplatePreviewWidget is a QPlainTextEdit designed to help visualize what a specific template would output given certain situations. @@ -42,7 +42,7 @@ def __init__(self, data_list, text=None, parent=None): :param list[dict] data_list: A list of dictionaries used to resolve a `sept.Template` in different scenarios. :param str text: Default text for the QPlainTextEdit. - :param QtGui.QWidget|None parent: Optional Qt parent widget. + :param QtWidgets.QWidget|None parent: Optional Qt parent widget. """ super(TemplatePreviewWidget, self).__init__(text, parent) self.setReadOnly(True)