diff options
Diffstat (limited to 'examples/demos/documentviewer/main.py')
-rw-r--r-- | examples/demos/documentviewer/main.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/examples/demos/documentviewer/main.py b/examples/demos/documentviewer/main.py new file mode 100644 index 000000000..2af373ef3 --- /dev/null +++ b/examples/demos/documentviewer/main.py @@ -0,0 +1,37 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +"""PySide6 port of the Qt Document Viewer demo from Qt v6.x""" + +import sys +from argparse import ArgumentParser, RawTextHelpFormatter + +from PySide6.QtWidgets import QApplication +from PySide6.QtCore import QCoreApplication + +from mainwindow import MainWindow + + +DESCRIPTION = "A viewer for JSON, PDF and text files" + + +if __name__ == "__main__": + + app = QApplication([]) + QCoreApplication.setOrganizationName("QtExamples") + QCoreApplication.setApplicationName("DocumentViewer") + QCoreApplication.setApplicationVersion("1.0") + + arg_parser = ArgumentParser(description=DESCRIPTION, + formatter_class=RawTextHelpFormatter) + arg_parser.add_argument("file", type=str, nargs="?", + help="JSON, PDF or text file to open") + args = arg_parser.parse_args() + fileName = args.file + + w = MainWindow() + w.show() + if args.file and not w.openFile(args.file): + sys.exit(-1) + + sys.exit(app.exec()) |