File: metaobject_dump.py

package info (click to toggle)
pyside6 6.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,904 kB
  • sloc: python: 202,640; cpp: 91,160; xml: 18,402; javascript: 1,182; ansic: 178; sh: 163; makefile: 87
file content (31 lines) | stat: -rw-r--r-- 786 bytes parent folder | download | duplicates (2)
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
29
30
31
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
from __future__ import annotations

import sys

from dump_metaobject import dump_metaobject
# Import all widget classes to enable instantiating them by type name
from PySide6.QtWidgets import *

DESC = """
metaobject_dump.py <class_name>

Dumps the QMetaObject of a class

Example: metaobject_dump QLabel
"""


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print(DESC)
        sys.exit(0)
    app = QApplication(sys.argv)

    type_name = sys.argv[1]
    type_instance = eval(type_name)
    if not type_instance:
        print(f'Invalid type {type_name}')
        sys.exit(1)
    dump_metaobject(type_instance.staticMetaObject)