Skip to content

Commit

Permalink
updated readme with explanation about the updated signal and an example
Browse files Browse the repository at this point in the history
  • Loading branch information
aardschok committed May 5, 2017
1 parent e84fc88 commit 0685fe0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,31 @@ modifier = QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier

menu = ScriptsMenu()
menu.register_callback(modifier, callback)
```

#### Update menu

The ScriptsMenu has a signal called "updated" which can be connected to a function which
rebuilds the menu

```python
# This example is tested in Autodesk Maya
import scriptsmenu.launchformaya as launchformaya

# Here we create our own menu without any scripts
menu = launchformaya.main(title="Custom Menu")

# Set the update button visible, which is hidden by default
menu.set_update_visible(True)

# Add a custom script to the menu
menu.add_script(parent=menu, title="Before", command='print("C")', sourcetype="python")

# Create update function
def update(menu):
menu.clear_menu()
menu.add_script(parent=menu, title="After", command='print("C")', sourcetype="python")

# Link the update function to the update signal
menu.updated.connect(update)
```

0 comments on commit 0685fe0

Please sign in to comment.