Need help with python/marking menu

by IrisHeart posted 23 days ago

I followed this guide on marking menus, https://bindpose.com/custom-marking-menus-maya-editors/ its work great for the most part, but not with one of my python scripts. The script is a simple UI with buttons that works on my shelf but when I open it with my custom marking menu it opens the UI but the buttons do not work its says "NameError: name 'foo' is not defined " when I click the button.

The only work around I've found is creating a mel script or runtime command that opens my script then running that with the marking menu. Is there a better more correct way to open python scripts with UI's in a marking menu without having this issue?