Closed GoogleCodeExporter closed 9 years ago
This works too:
with pm.window(menuBar=True):
pm.menu()
pm.menuItem()
with pm.subMenuItem():
pm.menuItem()
Regards.
Sebastien Courtois
Cyber Group Studios
Original comment by neitsabe...@gmail.com
on 9 Feb 2012 at 7:41
Curiously, this works fine too:
with pm.ui.PyUI("MayaWindow"):
with pm.menu():
pm.menuItem()
Original comment by neitsabe...@gmail.com
on 10 Feb 2012 at 9:27
Yikes... that's a pretty big problem. I know that SP2 introduced some changes
to speed up ui-name-lookups - which is awesome, since it should greatly speed
up pymel ui objects - but perhaps something else got changed in the process?
Anyway, looking into it...
Original comment by elron...@gmail.com
on 10 Feb 2012 at 7:46
Original comment by elron...@gmail.com
on 10 Feb 2012 at 7:47
It appears the root of the problem is a change in the behavior of objectTypeUI
- if you execute this code in 2012 SP1:
import maya.cmds as cmds
win = cmds.window(menuBar=True)
print cmds.objectTypeUI(win)
...it prints "floatingWindow".
However, if you run the same code snippet in SP2, you get an exception:
# Traceback (most recent call last):
# File "<maya console>", line 3, in <module>
# RuntimeError: objectTypeUI: Object 'window1' not found. #
Going to get this to autodesk, and hopefully they can get a fix for it. If it
looks like it's going to be a while, we can see what we can do on our side, but
it could get messy.... =/
Original comment by elron...@gmail.com
on 10 Feb 2012 at 8:26
A bugfix release that needs a bugfix... Annoying, indeed !
Digging out a bit, i found out that the freezing of Maya actually comes from an
unbroken "while" loop in the "uitypes.Menu.__exit__()" method :
...
parent = self
while True:
parent = parent.parent()
try:
cmds.setParent( parent, menu = True )
except RuntimeError:
continue
break
but now, it seems that "parent.parent()" may return an empty string in the case
of a Menu parented to a window's menubar.
So, waiting for a real fix, i've just changed the "while True" condition to
"while parent" and it did the trick for now.
Original comment by neitsabe...@gmail.com
on 11 Feb 2012 at 12:25
Well, autodesk is apparently looking into it... but in a meantime, added a fix
which makes PyUI(windowWithMenu) work correctly again (returning a Window
object, instead of the base PyUI)
also made a fix to the while True loop, catching cases where parent might
somehow end up as '' (but will still set parent to None in these cases, unlike
the "while parent" fix)
fixed in
https://github.com/LumaPictures/pymel/commit/01bc9e04d28456450d473a64c88318c9bfa
12e8e
Original comment by elron...@gmail.com
on 16 Feb 2012 at 2:56
Thanks so much !
Original comment by neitsabe...@gmail.com
on 21 Feb 2012 at 9:37
Original issue reported on code.google.com by
neitsabe...@gmail.com
on 9 Feb 2012 at 7:17