{"id":13678481,"url":"https://github.com/hanjinliu/magic-class","last_synced_at":"2026-03-06T00:10:53.233Z","repository":{"id":37007160,"uuid":"403602215","full_name":"hanjinliu/magic-class","owner":"hanjinliu","description":"Generate multifunctional and macro recordable GUIs from Python classes","archived":false,"fork":false,"pushed_at":"2025-11-16T11:55:29.000Z","size":30312,"stargazers_count":44,"open_issues_count":8,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-16T13:19:10.013Z","etag":null,"topics":["gui","qt"],"latest_commit_sha":null,"homepage":"https://hanjinliu.github.io/magic-class/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanjinliu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-09-06T11:47:24.000Z","updated_at":"2025-11-16T11:53:34.000Z","dependencies_parsed_at":"2023-10-21T13:28:47.499Z","dependency_job_id":"77ca751f-6643-4912-9184-61ae21108f1a","html_url":"https://github.com/hanjinliu/magic-class","commit_stats":{"total_commits":1550,"total_committers":8,"mean_commits":193.75,"dds":0.05935483870967739,"last_synced_commit":"26be3d43742c0ee1b25d28f248e14368e899f38a"},"previous_names":[],"tags_count":68,"template":false,"template_full_name":null,"purl":"pkg:github/hanjinliu/magic-class","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanjinliu%2Fmagic-class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanjinliu%2Fmagic-class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanjinliu%2Fmagic-class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanjinliu%2Fmagic-class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanjinliu","download_url":"https://codeload.github.com/hanjinliu/magic-class/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanjinliu%2Fmagic-class/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30156259,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"ssl_error","status_checked_at":"2026-03-05T22:39:24.771Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gui","qt"],"created_at":"2024-08-02T13:00:54.066Z","updated_at":"2026-03-06T00:10:53.222Z","avatar_url":"https://github.com/hanjinliu.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![BSD 3-Clause License](https://img.shields.io/pypi/l/magic-class.svg?color=green)](https://github.com/hanjinliu/magic-class/blob/main/LICENSE)\n[![Python package index download statistics](https://img.shields.io/pypi/dm/magic-class.svg)](https://pypistats.org/packages/magic-class)\n[![PyPI version](https://badge.fury.io/py/magic-class.svg)](https://badge.fury.io/py/magic-class)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/magic-class.svg)](https://pypi.org/project/magic-class)\n[![Conda version](https://anaconda.org/conda-forge/magic-class/badges/version.svg)](https://anaconda.org/conda-forge/magic-class/badges/version.svg)\n\n\n# magic-class\n\n![](https://github.com/hanjinliu/magic-class/blob/main/Figs/Example.gif)\n\n`magic-class` makes GUI development as easy as daily coding by converting well-typed Python class directly into GUI. It is powered by [magicgui](https://github.com/pyapp-kit/magicgui) and has a smooth interface with [napari](https://github.com/napari/napari). `magic-class` is also implemented with useful widgets such as `matplotlib` figure canvas, logger widget and color edit.\n\n#### Target users\n\n- Researchers who already have their Python functions and classes and are planing to take a step forward to improve the interface using GUI, with minimum effort.\n- Non-professional programmers who don't want to spend time on debugging and maintaining GUI.\n- Users who are not satisfied with the low reproducibility of the most of the GUI.\n- People who are familiar with `magicgui` and interested in more sophisticated GUI using typing.\n\n#### How magic-class solves your problems\n\n- Decorate your class with `@magicclass` and you are ready to use the class both in GUI and from console.\n- `@magicclass` implements macro-recorder in the class. You can easily create executable Python codes from the history of manual operations.\n- Your code looks almost \"Pythonic\". No need to be confused by messy class structure pecuilar to GUI development anymore.\n\n`magic-class` is work in progress. Feel free to report issues, make suggestions and contribute!\n\n## Documentation\n\nDocumentation is available [here](https://hanjinliu.github.io/magic-class/).\n\n## Installation\n\n- use pip\n\n```\npip install magic-class -U\npip install magic-class[pyqt5] -U  # with pyqt5 backend\n```\n\n- get the latest version\n\n```\npip install git+https://github.com/hanjinliu/magic-class.git\n```\n\n## Example\n\nLet's make a simple GUI that can load 1-D data and plot it.\n\n``` python\nfrom magicclass import magicclass\nfrom pathlib import Path\n\n@magicclass\nclass PlotData:\n    \"\"\"Load 1D data and plot it.\"\"\"\n\n    def load(self, path: Path):\n        \"\"\"\n        Load file.\n\n        Parameters\n        ----------\n        path : Path\n            File path\n        \"\"\"\n        self.data = np.loadtxt(str(path))\n\n    def plot(self):\n        \"\"\"Plot data.\"\"\"\n        plt.plot(self.data)\n        plt.show()\n```\n\nClasses decorated with `@magicclass` are converted to `magicgui`'s `Container` widgets. GUI starts with `show` method.\n\n``` python\nui = PlotData(title=\"Title\")\nui.show()\n```\n\nYou can continue analysis in console.\n\n``` python\nui.plot()\n```\n\nFor people doing image analysis, it can be added to a `napari` viewer as a dock widget.\n\n``` python\nimport napari\nviewer = napari.Viewer()\nviewer.window.add_dock_widget(ui)\n```\n\nExecutable Python code (so called \"macro\" in many GUI tools) is available in `macro` attribute.\n\n``` python\nprint(ui.macro)  # print macro\nui.macro.widget.show()  # open a text editor widget with macro written in\n```\n\nTo make nicer GUI, you can also nest `magic-class`:\n\n``` python\n@magicclass\nclass PlotData:\n    @magicclass\n    class Menu: ...\n```\n\nadd a menubar with `@magicmenu` decorator:\n\n``` python\n@magicclass\nclass PlotData:\n    @magicmenu\n    class File: ...\n    @magicmenu\n    class Edit: ...\n```\n\nadd context menu with `@magiccontext` decorator:\n\n``` python\n@magicclass\nclass PlotData:\n    @magiccontext\n    class contextmenu: ...\n        def Copy(self): ...\n        def Paste(self): ...\n\n```\n\ndirectly integrate `magicgui` and its widgets:\n\n``` python\n@magicclass\nclass PlotData:\n    line = LineEdit()\n    @magicgui\n    def load(self, path: Path): ...\n```\n\n... and so on.\n\nOther examples are in the \"examples\" folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanjinliu%2Fmagic-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanjinliu%2Fmagic-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanjinliu%2Fmagic-class/lists"}