diff options
Diffstat (limited to 'examples/xmlpatterns/schema/schema.py')
-rwxr-xr-x | examples/xmlpatterns/schema/schema.py | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/examples/xmlpatterns/schema/schema.py b/examples/xmlpatterns/schema/schema.py index bdc33df..1a3c51e 100755 --- a/examples/xmlpatterns/schema/schema.py +++ b/examples/xmlpatterns/schema/schema.py @@ -1,7 +1,47 @@ #!/usr/bin/env python - -from PySide2 import QtCore, QtGui, QtXmlPatterns +############################################################################# +## +## Copyright (C) 2013 Riverbank Computing Limited. +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the PySide examples of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of The Qt Company Ltd nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +from PySide2 import QtCore, QtGui, QtWidgets, QtXmlPatterns import schema_rc from ui_schema import Ui_SchemaMainWindow @@ -111,10 +151,10 @@ class MessageHandler(QtXmlPatterns.QAbstractMessageHandler): self.m_sourceLocation = sourceLocation -class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow): +class MainWindow(QtWidgets.QMainWindow, Ui_SchemaMainWindow): def __init__(self): - QtGui.QMainWindow.__init__(self) + QtWidgets.QMainWindow.__init__(self) self.setupUi(self) @@ -161,6 +201,9 @@ class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow): self.validate() def instanceSelected(self, index): + if index is -1: + return + index += 2 * self.schemaSelection.currentIndex() instanceFile = QtCore.QFile(':/instance_%d.xml' % index) instanceFile.open(QtCore.QIODevice.ReadOnly) @@ -211,7 +254,7 @@ class MainWindow(QtGui.QMainWindow, Ui_SchemaMainWindow): self.instanceEdit.moveCursor(QtGui.QTextCursor.Right) extraSelections = [] - selection = QtGui.QTextEdit.ExtraSelection() + selection = QtWidgets.QTextEdit.ExtraSelection() lineColor = QtGui.QColor(QtCore.Qt.red).lighter(160) selection.format.setBackground(lineColor) @@ -229,7 +272,7 @@ if __name__ == '__main__': import sys - app = QtGui.QApplication(sys.argv) + app = QtWidgets.QApplication(sys.argv) window = MainWindow() window.show() sys.exit(app.exec_()) |