Loading...
Loading...
Compare original and translation side by side
| Version | Key Features | EOL |
|---|---|---|
| 3.10 | | Oct 2026 |
| 3.11 | Exception groups, | Oct 2027 |
| 3.12 | Type parameter syntax | Oct 2028 |
| 3.13 | Experimental free-threaded mode, improved error messages | Oct 2029 |
| 3.14 | | Oct 2030 |
| 版本 | 核心特性 | 停止支持时间 |
|---|---|---|
| 3.10 | | 2026年10月 |
| 3.11 | 异常组、 | 2027年10月 |
| 3.12 | 类型参数语法 | 2028年10月 |
| 3.13 | 实验性无全局解释器锁模式、优化的错误提示 | 2029年10月 |
| 3.14 | | 2030年10月 |
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-app"
version = "1.0.0"
requires-python = ">=3.10"
dependencies = []
[project.optional-dependencies]
dev = ["pytest>=8.0", "ruff>=0.6", "mypy>=1.11"]
[project.scripts]
myapp = "my_app.__main__:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --strict-markers"
[tool.ruff]
target-version = "py310"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "TCH"]
[tool.mypy]
python_version = "3.10"
strict = true[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "my-app"
version = "1.0.0"
requires-python = ">=3.10"
dependencies = []
[project.optional-dependencies]
dev = ["pytest>=8.0", "ruff>=0.6", "mypy>=1.11"]
[project.scripts]
myapp = "my_app.__main__:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --strict-markers"
[tool.ruff]
target-version = "py310"
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "UP", "B", "SIM", "TCH"]
[tool.mypy]
python_version = "3.10"
strict = trueexe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas,
name='MyApp', console=False, icon='icon.ico')exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas,
name='MyApp', console=False, icon='icon.ico')exe = EXE(pyz, a.scripts, exclude_binaries=True,
name='MyApp', console=False, icon='icon.ico')
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='MyApp')exe = EXE(pyz, a.scripts, exclude_binaries=True,
name='MyApp', console=False, icon='icon.ico')
coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, name='MyApp')pkg_resources.externaccessible_output2keyring.backendsplatformdirshttpx._transportshttpcore._backendsencodingspkg_resources.externaccessible_output2keyring.backendsplatformdirshttpx._transportshttpcore._backendsencodings| Sizer | When to Use |
|---|---|
| Stack items top-to-bottom |
| Lay items left-to-right |
| Form layouts with labels + controls |
| Even grid layouts |
| Flow layout that wraps |
| Grouped controls with border |
| Sizer | 使用场景 |
|---|---|
| 从上到下堆叠元素 |
| 从左到右排列元素 |
| 带标签+控件的表单布局 |
| 均匀网格布局 |
| 可自动换行的流式布局 |
| 带边框的分组控件 |
undefinedundefinedundefinedundefined| ID | Purpose |
|---|---|
| OK button |
| Cancel button |
| Save action |
| Open action |
| Exit / Quit |
| Help action |
| New document |
| Undo / Redo |
| ID | 用途 |
|---|---|
| 确认按钮 |
| 取消按钮 |
| 保存操作 |
| 打开操作 |
| 退出操作 |
| 帮助操作 |
| 新建文档 |
| 撤销/重做 |
| Event | Trigger |
|---|---|
| Button click |
| Menu item selected |
| Window close requested |
| Window resized |
| Timer fired |
| Text control content changed |
| List item selected |
| Tree selection changed |
| UI state update check |
| 事件 | 触发条件 |
|---|---|
| 按钮点击 |
| 菜单项被选中 |
| 收到窗口关闭请求 |
| 窗口大小调整 |
| 计时器触发 |
| 文本控件内容变更 |
| 列表项被选中 |
| 树形控件选中项变更 |
| UI状态更新检查 |
def f(items=[])Nonelambda: xlambda x=x: xTYPE_CHECKINGfield()field()@dataclassis==is==isNoneTrueFalse"".join()io.StringIOdef f(items=[])Nonelambda: xlambda x=x: xTYPE_CHECKINGfield()field()@dataclassis==is==NoneTrueFalseis"".join()io.StringIOwx.CallAfter()wx.PostEvent()event.Skip()event.Skip()EVT_CLOSE_mgr.UnInit()with MyDialog(...) as dlg:SetPosition()SetSize()wx.CallAfter()wx.PostEvent()event.Skip()event.Skip()EVT_CLOSE_mgr.UnInit()with MyDialog(...) as dlg:SetPosition()SetSize()from platformdirs import user_config_dir, user_data_dir, user_cache_dir
config = user_config_dir("MyApp", "MyCompany") # %APPDATA% / ~/Library/... / ~/.config/
data = user_data_dir("MyApp", "MyCompany")
cache = user_cache_dir("MyApp", "MyCompany")from platformdirs import user_config_dir, user_data_dir, user_cache_dir
config = user_config_dir("MyApp", "MyCompany") # %APPDATA% / ~/Library/... / ~/.config/
data = user_data_dir("MyApp", "MyCompany")
cache = user_cache_dir("MyApp", "MyCompany")undefinedundefinedundefinedundefinedimport logging
def setup_logging(level: int = logging.INFO) -> None:
logging.basicConfig(
level=level,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# Quiet noisy libraries
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)import logging
def setup_logging(level: int = logging.INFO) -> None:
logging.basicConfig(
level=level,
format="%(asctime)s %(name)s %(levelname)s %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
# 降低噪杂库的日志级别
logging.getLogger("httpx").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)| Platform | API | Python Binding |
|---|---|---|
| Windows | UI Automation | |
| Windows | MSAA/IAccessible2 | |
| macOS | NSAccessibility | |
| 平台 | API | Python绑定 |
|---|---|---|
| Windows | UI Automation | |
| Windows | MSAA/IAccessible2 | |
| macOS | NSAccessibility | |
undefinedundefinedundefinedundefined