Skip to content

Commit

Permalink
Simplify __main__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MHendricks committed Jan 4, 2024
1 parent eb76681 commit ce393f0
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/pyqt_tools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
""" 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.
""" Enables support for calling entrypoints using `python -m`.
Examples:
Launching PyQt6 designer: `python -m pyqt6_tools designer`
Launching PyQt5 designer: `python -m pyqt5_tools designer`
"""


import importlib
import pathlib
import sys
from . import entrypoints

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())
sys.exit(entrypoints.main())

0 comments on commit ce393f0

Please sign in to comment.