{"id":33022514,"url":"https://github.com/theodox/mGui","last_synced_at":"2025-11-15T10:00:53.136Z","repository":{"id":14186307,"uuid":"16892683","full_name":"theodox/mGui","owner":"theodox","description":"Python module for cleaner maya GUI layout syntax","archived":false,"fork":false,"pushed_at":"2021-04-27T17:40:14.000Z","size":595,"stargazers_count":123,"open_issues_count":15,"forks_count":23,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-05-14T02:52:52.086Z","etag":null,"topics":["gui","maya","maya-python","mgui"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theodox.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-16T19:50:11.000Z","updated_at":"2024-09-17T20:13:42.000Z","dependencies_parsed_at":"2022-09-23T20:41:02.501Z","dependency_job_id":null,"html_url":"https://github.com/theodox/mGui","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/theodox/mGui","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodox%2FmGui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodox%2FmGui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodox%2FmGui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodox%2FmGui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theodox","download_url":"https://codeload.github.com/theodox/mGui/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theodox%2FmGui/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284538091,"owners_count":27022334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-15T02:00:06.050Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","maya","maya-python","mgui"],"created_at":"2025-11-13T19:00:34.925Z","updated_at":"2025-11-15T10:00:53.127Z","avatar_url":"https://github.com/theodox.png","language":"Python","funding_links":[],"categories":["Game-Design-Tool","Libraries","Tools, Pipeline \u0026 Utilities"],"sub_categories":["CG Software API","Scene \u0026 Pipeline Tools"],"readme":"# mGui \n### A module for simplifying Maya GUI coding\n\n## Basics\nmGui is a python module for simplifying GUI creation using Maya's built-in gui widgets. As such it is not a replacement for something more sophisticated, like PyQT or PySide - it's a way to make simple UI more quickly and reliably (and without the need for distributing any DLLs in older versions of Maya).\n\nThe goal is to provide the most consistent and least wordy way of creating simple GUI in Maya. Instead of this:\n\n```python\nitems = (\"pCube1\", \"pPlane2\")\nwindow  = cmds.window()\nw, margin = 400, 10\nmainform = cmds.formLayout( width=w ) \nmaincol = cmds.columnLayout( adj=True ) \nmain_attach = [( maincol, 'top', margin ), ( maincol, 'left', margin ), ( maincol, 'right', margin )]\ncol_w = int( ( w - ( margin * 2 ) ) / 3 ) - 1\ncmds.setParent( mainform ) \ndis_row = cmds.rowLayout( nc=3, ct3=( 'both', 'both', 'both' ), cw3=( col_w, col_w, col_w ) ) \ndis_attach = [( dis_row, 'bottom', margin ), ( dis_row, 'left', margin ), ( dis_row, 'right', margin )]\ncmds.formLayout( mainform, e=True, attachForm=main_attach + dis_attach ) \ncmds.formLayout( mainform, e=True, ac=( maincol, 'bottom', margin, dis_row ) ) \ncmds.setParent( dis_row ) \ncmds.button( \"Refresh\", width=col_w)\ncmds.text( ' ' ) \ncmds.button( \"Close\", width=col_w)\ncmds.setParent( maincol ) \ncmds.text( \" \" ) \ncmds.text( \"The following items don't have vertex colors:\", align='left' ) \ncmds.text( \" \" ) \nItemlist = cmds.textScrollList( numberOfRows=8, allowMultiSelection=True, append=items ) \ndis_row = cmds.rowLayout( nc=5, ct5=( 'both', 'both', 'both', 'both', 'both' ) ) \ncmds.showWindow(window)\n```\nyou can write this:\n```python\n\nbound = ObservableCollection(\"pCube1\", \"pPlane1\")\n\nwith BindingWindow(title = 'example window') as test_window:\n    with VerticalForm() as main:\n        Text(label = \"The following items don't have vertex colors\")\n        list_view = VerticalList()\n        list_view.bind.collection \u003c bind() \u003c bound\n        with HorizontalStretchForm() as buttons:\n            Button('refresh', l='Refresh')\n            Button('close', l='Close')\ntest_window.show()             \n```\nAnd make adjustments like this:\n```python\nmain.buttons.refresh.backgroundColor = (.7, .7, .5)\n```\n\n\n# Key parts\n\n## mGui.gui: object oriented gui classes\n\nThe main tool in the library is a complete wrapper set for for all of the widgets in the \nMaya GUI library in the module **mGui.gui**.  These wrapper classes are assembled using a \nspecial metaclass which allows you to get and set their properties with traditional dot \nnotation, rather than Maya's cumbersome command-based syntax.  Layouts, windows and menus are \ntreated as context managers,  allowing you to write neatly nested layouts and keep your \nlogical structure separate from the visual details.  The layouts also 'know' the names of their\nchildren, so that you can access controls directly through the hierarchy of your layout: \nin the example above, you can acces the 'close' button as\n```python\nexample_window.main.buttons.refresh\n```\nwithout doing any manual management of variables.\n\n\n## Styles\n\nTo make it easier to manage the visual look of your layouts -- and more importantly, to keep the\nvisuals separated cleanly from the logical structure of the code -- **mgui.Styles** creates\nstyle dictionaries which work very much like CSS styles in web design.  Styles can be targeted at \nindividual controls or entire classes of controls; they can be inherited and overridden for maximal\nflexibility.\n\n\n## Bindings\n\nA lot of repetitive GUI coding is simply about shuffling little bits of data around - setting the name\nof a button to match that of the selected item, changing the color of a field based on the state of \na checkbox, and so on.  \n\nIn order to simplify this process, **mGui.bindings** defines  _Bindings_ - classes which can get information\n from one place and putting it somewhere else in a structured way. Bindings can be created declaratively,\n rather than requiring you to manually manage the relationships. Thus\n```python\nText('example').bind.label \u003c bind() \u003c 'pCube1.tx'\n```\n will set the label of a text widget to the X-transform of pCube1, while\n \n     CheckBox('vis').bind.value \u003e bind() \u003e 'pCube1.visibility' \n     \n will tie the visibility of the cube to the state of the checkbox.\n \n The module `mGui.lists` provides a set of pre-built collection widgets designed for use with binding. The `VerticalList`, `HorizontalList`, `WrapList` and `ColumnList` will draw items in a scrolling list view for every item in their bound collections. The `itemTemplate` class allows you to create a custom widget display for any incoming data type, so you can create rich UIs with inline controls, multiple lines of data, and customizable styles.\n \n## Forms \n\nThe traditional Maya formLayout command is the most powerful and flexible type of layout. Unfortunately, it's also the most awkward to use. Attaching childrent to a form requires creating long chains of argument which are tough to read and to parse.\n\n**mGui.forms** provides a number of pre-built forms, which automatically attach their own children in predictable ways.  The key types are:\n\n*  **HorizontalForm** and **VerticalForm**.  As the names imply, these lay out their children horizontally or vertically, each child snapped to the previous one. The form expands but the children don't move. \n*  **HorizontalExpandForm** and **VerticalExpandForm** are similar to regular forms, except that the last child will expand with the form.  They are commonly used to divide an area between a header and content, or between a navigation column and content.\n*  **HorizontalStretchForm** and **VerticalStretchForm** will expand all their children as the overall form grows or shrink. Handy for things like maintaining evenly sized divisions in a window.\n*  **HorizontalThreePane** and **VerticalThreePane**  These form expect exactly three children. The first and last children are glues to the beginning and end of the form, respectively, while the middle child expands with the form. Handy for layouts with headers and footers or with tools surrounding a content pane.\n\n## Events\n\nMaya GUI widgets can fire callbacks, but they have several important limitations. In particular, vanilla \nMaya callbacks don't retain any knowledge of the widget which sent them, which obliges you to write complex \ncode to track callbacks to their sources and understand their context.\n\n**mGui.Events** introduces event delegates - classes which catch maya gui callbacks when they fire and add\nuseful information about the widget which raised the callback. These events can be forwarded to multiple handlers,\nso that a single button press can move an object in your scene, highlight a button, and print a message in the help\nline using 3 simple functions rather than one big monster with lots of unrelated moving parts.  \n\n\n# Installation\n\nThe directory **mGui** is a Python package. Simply drop a copy of it into a location that's visible to your python path. You can then import modules in the usual way.\n\n# Usage\n\nThe module **mGui.gui** contains most of the key components: the windows, buttons, layouts and so on (they are defined in other modules, particulary **mGui.core.controls** and **mGui.core.layouts**, but collected into the *gui** module for easier access in your code.  **mGui.gui** is safe for star imports -- as safe as it can be, anyway --  so a common idiom is\n```python\nfrom mGui.gui import *\n\nwith Window('example') as w:\n    with ColumnLayout('cl'):\n        Text('msg', 'Hello World!')\n```\nThe main components are named identically to their Maya.cmds counterparts except for the fact that, being classes rather than commands, they are capitalized. Thus  **cmds.button** becomes **mGui.gui.Button**. **cmds.window** becomes **mGui.gui.Window** and so on.\n\n# Learm more\n\nCheck out our [wiki pages](https://github.com/theodox/mGui/wiki).  We're always looking for volunteers to help us improve our documentation!\n\n----------------\n\nThis project is provided under the MIT License: it's free for any kind of use as long as you retain the copyright notice in *`mGui.__init__`*.  \n     \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodox%2FmGui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheodox%2FmGui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheodox%2FmGui/lists"}