从Python类型构建GUI
项目描述
使用魔法从类型注解构建GUI
📖 文档
https://pyapp-kit.github.io/magicgui/
安装
magicgui
使用 qtpy
支持同时使用 pyside2
和 pyqt5
后端。但是,您必须安装其中之一才能使 magicgui 正常工作。
使用 pip 安装
pip install magicgui[pyqt5]
# or
pip install magicgui[pyside2]
或使用 conda
conda install -c conda-forge magicgui pyqt # or pyside2 instead of pyqt
:information_source: 如果您想帮助我们扩展对其他后端的支持,请打开一个 问题。
基本用法
from magicgui import magicgui
from enum import Enum
class Medium(Enum):
Glass = 1.520
Oil = 1.515
Water = 1.333
Air = 1.0003
# decorate your function with the @magicgui decorator
@magicgui(call_button="calculate", result_widget=True)
def snells_law(aoi=30.0, n1=Medium.Glass, n2=Medium.Water, degrees=True):
import math
aoi = math.radians(aoi) if degrees else aoi
try:
result = math.asin(n1.value * math.sin(aoi) / n2.value)
return math.degrees(result) if degrees else result
except ValueError:
return "Total internal reflection!"
# your function is now capable of showing a GUI
snells_law.show(run=True)
但这只是开始!请参阅 文档 了解更多细节和用法示例。
贡献
欢迎贡献!
请参阅贡献指南。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。
源代码分发
magicgui-0.9.1.tar.gz (20.9 MB 查看哈希值)
构建分发
magicgui-0.9.1-py3-none-any.whl (124.2 kB 查看哈希值)