def defaultButtonPush(*args):
#valid = ""
valid = showUI.validFormatsLs.getValue()
#return valid
def showUI():
win_name = "Select Camera Format"
if cmds.window(win_name, exists = True):
cmds.deleteUI(win_name)
main_win = cmds.window(title = "Select Camera Format", width = 100, height = 50)
cmds.columnLayout()
validFormats = ['itemA-01', 'itemB-02', 'itemC-02', 'itemD-01', 'itemE-01', 'itemF-03']
validFormatsLs = pm.optionMenu (label = 'Select a format')
for item in validFormats:
cmds.menuItem(label = str(item))
cmds.button( label = 'Ok', aop = True, command = ('defaultButtonPush()'))
cmds.button( label = 'Cancel', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
cmds.showWindow( main_win )
showUI()
def pickAFormat():
...
...
mel.eval('CBdeleteConnection "camera01_cameraFlattenedShape.lensSqueezeRatio";')
showUI()
cmds.optionMenu('filmbackMenu', edit = True, value = ??? ) # value is to take the text selection from the showUI
Hi all, pardon my coding as it has really been a while since I have last touched on scripting. Currently I am trying to make some stuff work but keeps bumping into issues here and there.Really in need of some insights1. I am unable to return the text value from the selection in showUI
2. Prior to #1, when I tested without the showUI() function, it works where the Ok button does prints some stuff however the window is never closed upon clicking on the button. So my question here will be how do I close the window upon hitting the Ok button
WINDOW = None
def showUI():
global WINDOW
if WINDOW and cmds.window(WINDOW, exists=True):
cmds.deleteUI(WINDOW)
WINDOW = cmds.window(...)
3. Related to #1, I am trying to get the value - the text value from the selection and have it run in my main code - pcikAFormat() in the optionMenu command, value flag..
def handleMenuSelection(value):
print "menu selection changed!", value
showUI(handleMenuSelection)
4. Just wondering what is the best way that I can select the latest created node/item?
--
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/3b07d3e7-ed49-4ede-8993-eefff381a3cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Pardon the late reply and my slow progress in my code.I had wanted to update and insert my latest code but have forgotten about it. I chanced upon this code which is similar to what I had wanted but still I am having trouble getting my program to 'wait' for user selection before executing the rest of the program..def printObject(objectList, *args):
objectName = cmds.optionMenu(objectList, query = True, value = True)
print objectName
def showUI():
......validFormatsLs = cmds.optionMenu (label = 'Select a format')cmds.button(label = "Print selected option", command = partial(printObject, objectList))
And as for the last question on getting the latest created node...Currently in my program, there is a custom module which is something as follows: import createCam; createCam.newNode()Having that command does create a new node (this command is different from cmds.camera()), however after its creation, it does not select the new nodeand hence, I am hardcoding it in my current code which is not ideal case, in the event if it is either selecting the wrong cam which has already existed with the same name, or it will simply duplicate a new camera where the naming could 'versioned up' - eg. newCam1, newCam2 etc
--
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/f3eab61e-28ca-4fca-bb36-da2125da547f%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/73f2cf52-d322-442c-94bc-261fcd7c8990%40googlegroups.com.