pathButtonGrp and folderButtonGrp will create two instances when a parent is specified, although the second instance in the UI is non-functional. textFieldGrp doesn't have the same problem.
def make_window():
win = pm.window()
fl = pm.frameLayout()
layout = pm.formLayout(parent=fl)
fbg = pm.pathButtonGrp(parent=layout)
layout.redistribute()
for x in layout.getChildren():
print x
return win
import pymel.core as pm
w = make_window()
w.show()
As far as my primitive understanding goes, the problem is in pymel.core.uitypes.PyUI.__new__(), which creates the extra, non-functional instance despite receiving create=False.
I've worked around for myself it by pushing parent=None into kwargs before the super but I'm not smart enough to know what damage I might be doing...
class PathButtonGrp(TextFieldButtonGrp):
PROMPT_FUNCTION = 'promptForPath'
def __new__(cls, name=None, create=False, *args, **kwargs):
if create:
import windows
kwargs.pop('bl', None)
kwargs['buttonLabel'] = 'Browse'
kwargs.pop('bc', None)
kwargs.pop('buttonCommand', None)
name = cmds.textFieldButtonGrp(name, *args, **kwargs)
promptFunction = getattr(windows, cls.PROMPT_FUNCTION)
def setPathCB(name):
f = promptFunction()
if f:
cmds.textFieldButtonGrp(name, e=1, text=f, forceChangeCommand=True)
import windows
cb = windows.Callback(setPathCB, name)
cmds.textFieldButtonGrp(name, e=1, buttonCommand=cb)
kwargs['parent']=None #Hack with unknown consequences
return super(PathButtonGrp, cls).__new__(cls, name, create=False, *args, **kwargs)
pathButtonGrp
andfolderButtonGrp
will create two instances when a parent is specified, although the second instance in the UI is non-functional.textFieldGrp
doesn't have the same problem.Printed output:
When the parent isn't specified, only one is created...
As far as my primitive understanding goes, the problem is in
pymel.core.uitypes.PyUI.__new__()
, which creates the extra, non-functional instance despite receivingcreate=False
.I've worked around for myself it by pushing
parent=None
into kwargs before thesuper
but I'm not smart enough to know what damage I might be doing...