--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/16e3c45b-8fba-4542-83a9-750fbc0e1ce4n%40googlegroups.com.
def printNewMenuItem( item ):
print itemThis code alone ALWAYS produces a invalid syntax on my end, so I am unable to check if that even works, or how it even works. I have looked at the documentation and am unable to find a workaround while looking at either of those documentation sites.
Any ideas?--On Tuesday, December 20, 2022 at 5:14:28 PM UTC-7 justin...@gmail.com wrote:Hi Kat,Have a look here:
https://help.autodesk.com/cloudhelp/2022/ENU/Maya-Tech-Docs/CommandsPython/optionMenu.html"Note that commands attached to menu items will not get called. Attach any commands via the -cc/changedCommand flag."And specifically the changeCommand:The example at the bottom of the page actually shows you how to use the callback, which will receive the value of the menuItem when it is changed in the optionMenu.JustinOn Wed, Dec 21, 2022 at 1:11 PM Kat Patterson <katier...@gmail.com> wrote:https://pastebin.com/SfLxjFmGOn Tuesday, December 20, 2022 at 5:09:19 PM UTC-7 Kat Patterson wrote:I am in need of some help, not sure how active this forum is anymore.I am looking to see if there is any way to make a optionMenu run a command for each option in the drop down menu? I am pretty new to maya python so I do not know very much, but google is less helpful than finding everything out myself.Here is the code that i currently have, I just am not sure how to connect the commands to the actual window ui;--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/16e3c45b-8fba-4542-83a9-750fbc0e1ce4n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e49e0fb6-aceb-4549-b406-e76fb5025476n%40googlegroups.com.
Okay so that did help, but now I am back to how do I add it to each individual command (i posted my code, it is a menu that creates an object, and another option to duplicate that object said amount of times) and how do I add the button into the mix to make said dropdown options run
def printNewMenuItem(item):
if item == "Sphere":
printSphere()
elif item == "Cube":
printCube()
def printSphere():
print("It's a sphere!")
def printCube():
print("It's a cube!")
menuCallbacks = {
"Sphere": printSphere,
"Cube": printCube,
}
def printNewMenuItem(item):
cbk = menuCallbacks.get(item)
if cbk:
cbk()
else:
print("Oops. I didnt define a callback for {}".format(item))
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/b99ee3df-4f2f-4134-b1e3-aaaa6ceb062dn%40googlegroups.com.
This helped greatly! Thank you so very much!!I do have one last question, do you know of a way to make the the changes of the dropdown menus only run off of a press of a button? (as in i have a 'create' button next to each dropdown menu). As in if i change the option to 'sphere' it doesnt change it when i press the option, it changes if i press the create button?It is alright if there is not an option like this, I am very greatful for you helping me ♥
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/925ee055-efed-4ce0-8ece-bb3a7cca50ben%40googlegroups.com.