Thats what i thought. But the optionMenu was the simple example. The same problem seems to apply to a lot of things, but mostly, if you are writing ui's using 'with' statements, and you stop using it, for perhaps an optionMenu, it seems you may not then continue the 'with' statements afterwards. This is definitly the case with frameLayouts and tabLayouts..only works once, then you can't go back into a 'with'. What i was trying to do was to use a tabLayout in a formLayout, in a frameLayout, as you do, then on one of the tabs, it was to contain another frameLayout with a form and another set of tabs. In fact, tabs just don't work using 'with' at all, because you have to edit the formlayout with tab descriptions from within the 'with' indent level which fsils saying it can't find the forLayout, even though you've both named it and decalred it 'with ... as .. ' and not even if you give the full path to the formLayout.
I though 'with' statements were put there to auf ui design by allowing you to use mel style indenting for clearer ui code sectioning. But it seems it just does'nt work. Sent from my iPhone On 12 Nov 2011, at 23:46, Justin Israel <[email protected]> wrote: > 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 -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
