aboutsummaryrefslogtreecommitdiffstats
path: root/examples/networkauth/redditclient/main.py
blob: e88e32cc5ed29b98380e5c8b001639c6b6a9c725 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

"""PySide6 port of the networkauth redditclient example from Qt v6.x"""

from argparse import ArgumentParser, RawTextHelpFormatter
import sys

from PySide6.QtWidgets import QApplication, QListView

from redditmodel import RedditModel


if __name__ == '__main__':
    parser = ArgumentParser(description='Qt Reddit client example',
                            formatter_class=RawTextHelpFormatter)
    parser.add_argument('--client', '-i', type=str, help='Client id')
    options = parser.parse_args()
    if not options.client:
        print('Specify a client id', file=sys.stderr)
        sys.exit(-1)

    app = QApplication(sys.argv)
    view = QListView()
    model = RedditModel(options.client)
    view.setModel(model)
    view.show()
    sys.exit(app.exec())