Seems like a bug in PyMel... Class OptionMenu -> PopupMenu -> Menu Menu has a makeDefault() command that is called from the __enter__() context switch and tries to setParent(menu=True) But an optionMenu does not allow a setParent() command to be called on it...
Example: win = cmds.window() cmds.columnLayout() m = cmds.optionMenu() cmds.setParent(m, menu=True) # RuntimeError: setParent: Object 'window3|columnLayout6|optionMenu4' not found. # Solution is probably don't use a with statement on the OptionMenu, as the context switching is not set up correctly. -- justin On Nov 7, 2011, at 8:33 AM, simon payne wrote: > So I am having a few issues using with statements to tab out my UI > code. below is a very simplistic example. The biggest problem is that > when laying out tabLayouts, you must first declare a formLayout, then > the tabLayout, then edit the form to attach the tabs. If you try this > entirely within 'with' statements it fails. If you remove the 'with' > statement from the line to edit the form and leave as pyMel, it works > fine...BUT, it seems you cannot then continue using 'with' statements > for the content of that tab. The following code uses the example from > the pyMel docs, which fails for the same reason : > > from __future__ import with_statement > from pymel.core import * > template = uiTemplate( 'ExampleTemplate', force=True ) > template.define( button, width=100, height=40, align='left' ) > template.define( frameLayout, borderVisible=True, labelVisible=False ) > > with window(menuBar=True,menuBarVisible=True) as win: > # start the template block > with template: > with columnLayout( rowSpacing=5 ): > with frameLayout(): > with columnLayout(): > button( label='One' ) > checkBox() > with frameLayout(): > button() > with optionMenu() as optM: > menuItem (l='test') > menuItem (l='test2') > > ##### However, if we use : > optionMenu() > menutItem(l='test') > > it works just fine. > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
