Skip to content

Commit

Permalink
Enable use with python -m or pythonw -m
Browse files Browse the repository at this point in the history
  • Loading branch information
MHendricks committed Jan 3, 2024
1 parent 51fd15b commit eb76681
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ Note:
Usage
-----

A program is provided available as ``Scripts/pyqt6-tools.exe``. There are
subcommands provided for each of Designer, QML Scene, and the QML Test Runner.
A program is provided available as ``Scripts/pyqt6-tools.exe`` or ``python -m pyqt6_tools``.
There are subcommands provided for each of Designer, QML Scene, and the QML Test Runner.
These wrapper commands provide additional functionality related to launching
the underlying programs. A larger set of Qt application are available as
subcommands of the ``Scripts/qt6-tools.exe`` program. In both cases, passing
Expand Down
19 changes: 19 additions & 0 deletions src/pyqt_tools/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
""" Enables support for calling entrypoints using `python -m` or `pythonw -m`.
On windows using `pythonw -m pyqt6_tools designer` in a shortcut allows opening
QtDesigner without showing a command prompt window that stays open the entire
time that QtDesigner is open.
"""


import importlib
import pathlib
import sys

if __name__ == "__main__":
# Relative imports don't work when called by `python -m ...`, get the name
# of the parent folder so we can import entrypoints from it. This is needed
# because the package name is not hard coded between PyQt versions.
module_name = pathlib.Path(__file__).parent.stem
entrypoints = importlib.import_module(f"{module_name}.entrypoints")

sys.exit(entrypoints.main())

0 comments on commit eb76681

Please sign in to comment.