{"id":23472912,"url":"https://github.com/colorbleed/scriptsmenu","last_synced_at":"2025-04-14T18:42:15.211Z","repository":{"id":19554471,"uuid":"87323780","full_name":"Colorbleed/scriptsmenu","owner":"Colorbleed","description":"Configurable scripts menu with search field in Qt","archived":false,"fork":false,"pushed_at":"2022-05-06T18:24:28.000Z","size":114,"stargazers_count":20,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T07:11:18.377Z","etag":null,"topics":["gui","qt","scripts-collection"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Colorbleed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-05T15:09:02.000Z","updated_at":"2024-01-20T19:32:44.000Z","dependencies_parsed_at":"2022-08-08T14:15:13.032Z","dependency_job_id":null,"html_url":"https://github.com/Colorbleed/scriptsmenu","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Colorbleed%2Fscriptsmenu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Colorbleed%2Fscriptsmenu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Colorbleed%2Fscriptsmenu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Colorbleed%2Fscriptsmenu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Colorbleed","download_url":"https://codeload.github.com/Colorbleed/scriptsmenu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248938337,"owners_count":21186386,"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","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","scripts-collection"],"created_at":"2024-12-24T17:14:26.434Z","updated_at":"2025-04-14T18:42:15.175Z","avatar_url":"https://github.com/Colorbleed.png","language":"Python","readme":"# scriptsmenu\n\n###  Searchable scripts menu with search field in Qt\n\nScriptsmenu will help you to easily organize your scripts into a\ncustomizable menu that users can quickly browse and search.\n\n\u003cbr\u003e\n\n#### Features\n- Built with [Qt.py](https://github.com/mottosso/Qt.py)\n- Searchable menu for your scripts and tools (using _tags_)\n- Update your scripts menu without restarting application\n- Supports use of [relative paths for scripts](#relative_paths)\n\n\u003cbr\u003e\n\n#### Installation\n\nTo install download this package and place it on your `PYTHONPATH`.\n\n\u003cbr\u003e\n\n#### Usage\n\nTo build a simple menu of searchable scripts\n\n```python\nfrom scriptsmenu import ScriptsMenu\n\nmenu = ScriptsMenu(title=\"Scripts\",\n                   parent=None)\nmenu.add_script(parent=menu,\n                title=\"Script A\",\n                command=\"print('A')\",\n                sourcetype='python',\n                tags=[\"foobar\", \"nugget\"])\nmenu.add_script(parent=menu,\n                title=\"Script B\",\n                command=\"print('B')\",\n                sourcetype='python',\n                tags=[\"gold\", \"silver\", \"bronze\"])\nmenu.show()\n```\n\n##### Example usage in Autodesk Maya\n\nTo parent the scripts menu to an application you'll need a parent Qt widget from the host application.\nYou can pass this parent as parent to the `ScriptMenu(parent=parent)`.\n\nAdditionally if you want to alter the behavior when clicking a menu item with specific modifier buttons held (e.g. Control + Shift) you can register a callback. See the _Register callback_ example under _Advanced_ below.\n\nAn example for Autodesk Maya can be found in `launchformaya.py`\n\nTo show the menu in Maya:\n\n```python\nimport scriptsmenu.launchformaya as launchformaya\n\nmenu = launchformaya.main(title=\"My Scripts\")\n\n# continue to populate the menu here\n```\n\nThis will automatically parent it to Maya's main menu bar.\n\nTo show the menu at Maya launch you can add code to your `userSetup.py`. This code will need to be executed deferred to ensure it runs when Maya main menu bar already exist. For example:\n\n```python\nimport maya.utils\nimport scriptsmenu.launchformaya as launchformaya\n\ndef build_menu():\n    menu = launchformaya.main(title=\"My Scripts\")\n\nmaya.utils.executeDeferred(build_menu)\n```\n\nAn example for The Foundry Nuke can be found in `launchfornuke.py`\n\nTo show the menu in Nuke:\n\n```python\nimport scriptsmenu.launchfornuke as launchfornuke\n\nmenu = launchfornuke.main(title=\"My Scripts\")\n\nmenu.add_script(parent=menu,\n                title=\"Script A\",\n                command=\"print('A')\",\n                sourcetype='python',\n                tags=[\"foobar\", \"nugget\"])\n\nmenu.add_script(parent=menu,\n                title=\"Script B\",\n                command=\"print('B')\",\n                sourcetype='python',\n                tags=[\"gold\", \"silver\", \"bronze\"])\n\n```\nAn example for The Foundry Mari can be found in `launchformari.py`\n\nTo show the menu in Mari:\n\n```python\nimport scriptsmenu.launchformari as launchformari\n\nmenu = launchformari.main(title=\"My Scripts\")\n\nmenu.add_script(parent=menu,\n                title=\"Script A\",\n                command=\"print('A')\",\n                sourcetype='python',\n                tags=[\"foobar\", \"nugget\"])\n\nmenu.add_script(parent=menu,\n                title=\"Script B\",\n                command=\"print('B')\",\n                sourcetype='python',\n                tags=[\"gold\", \"silver\", \"bronze\"])\n\n```\n##### Configuration\n\nThe menu can be reconstructed with help of a `.json` configuration file.\nThe configuration of the menu is a list of dictionaries. The loader recognizes three types;\n\n* `menu`, a submenu for the main menu with its own actions\n  * this is indicated with the key `\"items\"`\n* `action`, a script to run\n* `separator`, this is an aesthetical option but can help with separating certain actions which belong\nto the same group.\n\nThe order the items appear in the list dictates the order in which is will be created.\n\n```json\n[\n     {\n        \"type\": \"action\",\n        \"title\": \"Run Sanity Check\",\n        \"command\": \"$SCRIPTSFOLDER\\\\general\\\\sanity_check.py\",\n        \"sourcetype\": \"file\",\n        \"tags\": [\"general\",\"checks\",\"pipeline\"],\n        \"tooltip\": \"Run the sanity check to ensure pipeline friendly content\"\n    },\n    {\n        \"type\": \"separator\"\n    },\n    {\n        \"type\": \"menu\",\n        \"title\": \"Animation\",\n        \"items\":[\n            {\n                \"type\": \"action\",\n                \"title\": \"Blendshapes UI\",\n                \"command\": \"$SCRIPTSFOLDER\\\\animation\\\\blendshapes_ui.py\",\n                \"sourcetype\": \"file\",\n                \"tags\": [\"animation\",\"blendshapes\",\"UI\"],\n                \"tooltip\": \"Open the Blendshapes UI\"\n            }\n        ]\n    }\n]\n```\n\n\u003cbr\u003e\n\n### Advanced\n\n\n#### Relative paths\u003ca name=\"relative_paths\"\u003e\u003c/a\u003e\n\nTo use relative paths in your scripts and icons you can use environment variables. Ensure the\nenvironment variable is set correctly and use it in the paths, like `$YOUR_ENV_VARIABLE`.\n\nA relative path for example could be set as `$SCRIPTS/relative/path/to/script.py`\nAn example of this can be found in the samples folder of this package.\n\n#### Register callback\n\nYou can override the callback behavior per modifier state. For example when you want special\nbehavior when a menu item is clicked with _Control + Shift_ held at the same time.\n\n```python\nfrom Qt import QtCore\nfrom scriptsmenu import ScriptsMenu\n\ndef callback(action):\n    \"\"\"This will print a message prior to running the action\"\"\"\n    print(\"Triggered with Control + Shift\")\n    action.run_command()\n\n# Control + Shift\nmodifier = QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier\n\nmenu = ScriptsMenu()\nmenu.register_callback(modifier, callback)\n```\n\n#### Update menu\n\nThe ScriptsMenu has a signal called \"updated\" which can be connected to a function which\nrebuilds the menu\n\n```python\n# This example is tested in Autodesk Maya\nimport scriptsmenu.launchformaya as launchformaya\n\n# Here we create our own menu without any scripts\nmenu = launchformaya.main(title=\"Custom Menu\")\n\n# Set the update button visible, which is hidden by default\nmenu.set_update_visible(True)\n\n# Add a custom script to the menu\nmenu.add_script(parent=menu, title=\"Before\", command='print(\"C\")', sourcetype=\"python\")\n\n# Create update function\ndef update(menu):\n    menu.clear_menu()\n    menu.add_script(parent=menu, title=\"After\", command='print(\"C\")', sourcetype=\"python\")\n\n# Link the update function to the update signal\nmenu.updated.connect(update)\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorbleed%2Fscriptsmenu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolorbleed%2Fscriptsmenu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolorbleed%2Fscriptsmenu/lists"}