Skip to content

Commit b63134e

Browse files
committed
Add "Run as Script" program entry
增加以脚本形式启动主程序的入口方式;
1 parent 68fad69 commit b63134e

4 files changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ pip install py2exe-gui
4848

4949
Run:
5050

51+
```shell
52+
py2exe-gui
53+
```
54+
55+
You can run py2exe-gui as a package if running it as a script doesn't work:
56+
5157
```shell
5258
python -m py2exe_gui # `_`, not `-`
5359
```

README_zh.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ pip install py2exe-gui
4848

4949
运行
5050

51+
```shell
52+
py2exe-gui
53+
```
54+
55+
如果以脚本形式运行失败,还可以尝试作为 Python 包运行:
56+
5157
```shell
5258
python -m py2exe_gui # 注意连字符为_
5359
```

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ exclude = ["src/py2exe_gui/Resources/Icons", "src/py2exe_gui/Resources/Texts"]
1212
[tool.poetry.urls]
1313
"Bug Tracker" = "https://github.com/muziing/Py2exe-GUI/issues"
1414

15+
[tool.poetry.scripts]
16+
py2exe-gui = 'py2exe_gui.__main__:main'
17+
1518
#[[tool.poetry.source]]
1619
#name = "tsinghua_mirror"
1720
#url = "https://pypi.tuna.tsinghua.edu.cn/simple/"

src/py2exe_gui/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ def closeEvent(self, event: QCloseEvent) -> None:
5757
super().closeEvent(event)
5858

5959

60-
if __name__ == "__main__":
60+
def main():
61+
"""
62+
应用程序主入口函数
63+
"""
64+
6165
app = QApplication(sys.argv)
6266
window = MainApp()
6367
window.show()
6468
sys.exit(app.exec())
69+
70+
71+
if __name__ == "__main__":
72+
main()

0 commit comments

Comments
 (0)