Skip to main content

build GUIs from functions, using magic

Project description

icon

License Version conda-forge Python Version Build Status codecov

magicgui: build GUIs from functions, using magic.

📖 Docs

Installation

magicgui uses qtpy to support both pyside2 and pyqt5 backends. However, you must have one of those installed for magicgui to work.

install with pip

pip install magicgui[pyqt5]
# or
pip install magicgui[pyside2]

or with conda:

conda install -c conda-forge magicgui pyqt  # or pyside2 instead of pyqt

:information_source: If you'd like to help us extend support to a different backend, please open an issue.

Basic usage

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)

snells

But that's just the beginning! Please see Documentation for many more details and usage examples.

Contributing

Contributions are welcome!

Please note: magicgui attempts to adhere to strict coding rules and employs the following static analysis tools to prevent errors from being introduced into the codebase:

To prevent continuous integration failures when contributing, please consider installing pre-commit in your environment to run all of these checks prior to checking in new code.

pre-commit install

Changelog

v0.2.5 (2021-01-13)

Full Changelog

v0.2.5 greatly improves support for binding a value or a callback to a function parameter, and fixes a bug in recursively updating categorical widgets nested deeply inside of a container.

Merged pull requests:

v0.2.4 (2021-01-12)

Full Changelog

Merged pull requests:

  • Extend combobox api with set_choice, get_choice, del_choice #92 (tlambert03)

v0.2.3 (2021-01-08)

Full Changelog

v0.2.3 adds two new widgets DateEdit and TimeEdit (for datetime.date and datetime.time types respectively), in addition to the existing DateTimeEdit widget. It also continues to improve warnings and deprecation messages from the v0.2.0 release.

Fixed bugs:

  • magicgui.widgets.CategoricalWidget not found in magicgui 0.2.1 #81

Closed issues:

  • QTimeEdit widgets #78

Merged pull requests:

v0.2.2 (2021-01-02)

Full Changelog

Merged pull requests:

v0.2.1 (2020-12-29)

Full Changelog

v0.2.1 fixes some issues with the 0.2.0 release. ForwardRef annotations are now resolved automatically on both parameter and return type annotations. And the orientation parameter on Container widgets (such as those returned by the magicgui decorator) has been renamed back to layout as in <v0.2.0. Test coverage is also improved.

Fixed bugs:

  • napari examples in the docs are broken #72
  • Functions without arguments are not finding napari parent widgets #64
  • "Layout" parameter doesn't work anymore in recent dev version #54

Closed issues:

  • Should we permanently resolve ForwardRef type annotations? #65
  • Need consensus on "layout" vs "orientation" #63

Merged pull requests:

v0.2.0 (2020-12-26)

Full Changelog

v0.2.0 includes a complete rewrite of magicgui. The primary goals were as follows:

  • make a clean separation between the Qt backend and the end-use API, clarifying the interface that a backend must implement in order to work with magicgui
  • create a "direct API" that enables procedural widget creation, with the potential for subclassing and custom widget creation
  • create a more direct link between an individual widget and an inspect.Parameter object, and a collection or layout of widgets and an inspect.Signature object.

See PR #43 for full details of the rewrite.

Deprecations and possible breaking changes!

Some of the API has been deprecated or changed, though an attempt was made to make the pre-0.2.0 API still work (with warnings). Please see the v0.2.0 migration guide for details.

Lastly, we have new documentation, using the amazing jupyter-book project! Note the new url at https://napari.org/magicgui

Implemented enhancements:

  • Provide more direct "autowidget generation" without requiring function body. #7

Fixed bugs:

  • call_button not responding #44
  • Removal of docks: are widgets singletons? #28

Closed issues:

  • Enable magicgui decorator on class member functions #53
  • Recognize widget types as strings #47
  • Recognize napari layer types as strings #46
  • Widget label editable #45
  • Add support for Annotated type #34
  • Pull signature parsing code from MagicGuiBase #33

Merged pull requests:

v0.1.6 (2020-07-23)

Full Changelog

v0.1.6rc0 (2020-07-23)

Full Changelog

Implemented enhancements:

  • Use eval'd text box as fallback when type inference fails #29

Closed issues:

  • conda recipe #21
  • Feature request: support for QFileDialog (file and directory choosers) #20
  • Unable to visualize QBoxlayout nor QTable #12

Merged pull requests:

v0.1.5 (2020-05-24)

Full Changelog

Fixed bugs:

  • Error running examples #6

Closed issues:

  • Automagically add labels per field #13

Merged pull requests:

v0.1.4 (2020-05-19)

Full Changelog

Merged pull requests:

v0.1.3 (2020-05-04)

Full Changelog

Merged pull requests:

v0.1.2 (2020-03-06)

Full Changelog

Closed issues:

  • Register callbacks on return types #3

Merged pull requests:

v0.1.1 (2020-02-19)

Full Changelog

Merged pull requests:

v0.1.0 (2020-02-18)

Full Changelog

Merged pull requests:

v0.0.8 (2020-02-11)

Full Changelog

v0.0.7 (2020-02-09)

Full Changelog

v0.0.6 (2020-02-09)

Full Changelog

* This Changelog was automatically generated by github_changelog_generator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

magicgui-0.2.6.tar.gz (20.8 MB view details)

Uploaded Source

Built Distribution

magicgui-0.2.6-py2.py3-none-any.whl (100.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file magicgui-0.2.6.tar.gz.

File metadata

  • Download URL: magicgui-0.2.6.tar.gz
  • Upload date:
  • Size: 20.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for magicgui-0.2.6.tar.gz
Algorithm Hash digest
SHA256 c9fb4020eebc1bbdbeff54ddf6ffb6cae83dc1927253356b190c190841ae667f
MD5 50d302e778e13490ff8820c0ac8dd28c
BLAKE2b-256 f2ba46d9fcace8ede0eb9b09e7db03a52a7e68ef6ee5626759c7544cdf1f231d

See more details on using hashes here.

File details

Details for the file magicgui-0.2.6-py2.py3-none-any.whl.

File metadata

  • Download URL: magicgui-0.2.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 100.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for magicgui-0.2.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b1cab52a3cbb519f86734fd1e75356e397a572a32b7176bbb9b98b3846ec16b8
MD5 4af37c9f67d27804c573ff0b6e996119
BLAKE2b-256 0840ae0d0f6c89a6a20f7c5172e696fc1cfa6b0da9f187b083165e67d6c4d7c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page