maya dockControl problem

338 views
Skip to first unread message

ozgun...@playanim.com

unread,
Sep 12, 2014, 10:04:13 AM9/12/14
to python_in...@googlegroups.com
Hi

(sorry for my english)

I'm having a hard time about this. So my problem is, when i just create a window and put some controls (textField, textFieldGrp) in it. Editing or querying with class methods is not a problem. but when i use dockControl to build my ui, maya cannot find "_grp" controls

here i post some code:
textField querying is working, but textField querying is not (error message below)
maya can't find the control. even i print its name and its same as the name in the error message.

is it a known bug ?

(by the way, if i change textFieldGrp command to textField, it works)
(and if i change this to a window (not dock) it works either)

import maya.cmds as mc

class SimpleUI(object):
def __init__(self, *args):
self.wg={}
self.wg['win'] = 'MySimpleWindow'
self.wg['dock'] = 'MySimpleDock'

if mc.dockControl(self.wg['dock'], exists=True):
mc.deleteUI(self.wg['dock'])
# window
mc.window(self.wg['win'])
# layout
mc.rowColumnLayout(nc=1)
""" controls """
mc.button(l='textField_button',
c=self.com_button_command)
# this works
self.wg['textField'] = mc.textField()
mc.button(l='textFieldGrp_button',
c=self.com_grp_button_command)
# this does not work
self.wg['textFieldGrp'] = mc.textFieldGrp()
mc.dockControl(self.wg['dock'],
area='left',
content=self.wg['win'])

def com_button_command(self, *args):
# this works
mc.textField(self.wg['textField'], e=True, tx='blabla')

def com_grp_button_command(self, *args):
# this does not work
mc.textFieldGrp(self.wg['textFieldGrp'], e=True, tx='blabla')

SimpleUI()


"""Error Code"""

Mahmoodreza Aarabi

unread,
Sep 12, 2014, 4:39:25 PM9/12/14
to python_in...@googlegroups.com
Hey
i fix it in this way: (not professional manner in writing code, but it works for you now)
name = mc.textFieldGrp()
self.wg['textFieldGrp'] = name.split('|')[-1]

new code:

import maya.cmds as mc

class SimpleUI(object):
    def __init__(self, *args):
        self.wg={}
        self.wg['win'] = 'MySimpleWindow'
        self.wg['dock'] = 'MySimpleDock'

        if mc.dockControl(self.wg['dock'], exists=True):
            mc.deleteUI(self.wg['dock'])
        # window
        mc.window(self.wg['win'])
        # layout
        mc.rowColumnLayout(nc=1)
        """ controls """
        mc.button(l='textField_button',
                  c=self.com_button_command)
        # this works
        name = mc.textField()
        self.wg['textField'] = name.split('|')[-1]

        mc.button(l='textFieldGrp_button',
                  c=self.com_grp_button_command)
        # this does not work
        name = mc.textFieldGrp()
        self.wg['textFieldGrp'] = name.split('|')[-1]

        mc.dockControl(self.wg['dock'],
                       area='left',
                       content=self.wg['win'])

    def com_button_command(self, *args):
        # this works
        mc.textField(self.wg['textField'], e=True, tx='blabla')

    def com_grp_button_command(self, *args):
        # this does not work
        mc.textFieldGrp(self.wg['textFieldGrp'], e=True, tx='blabla')

SimpleUI()

good luck


--
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/195e1b55-5bcb-4248-8a63-7b13d6d90bf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia

Justin Israel

unread,
Sep 12, 2014, 5:24:06 PM9/12/14
to python_in...@googlegroups.com
What is annoying is that when you set the window into the dockControl, Maya changes a bunch of the parenting/path references for those existing controls in your window. So the path you stored, before having set the window into the dockControl, is no longer valid after the dockControl. But Maya does keep naming controls sequentially on a global level, so the short name would still be valid after splitting. It would have been cool if they thought to expose a form of an object id, specifically through the Maya commands, such as a guid. That way you could retain a reference that is always valid no matter where an object lives in the hierarchy or what is it named. 

özgün zümrüt

unread,
Sep 15, 2014, 3:00:23 PM9/15/14
to python_in...@googlegroups.com
hi, 
thanks mahmoodreza, justin. yes i found that grandchild name works but it's very annoying that some widgets work others not. 
and you're right about that this is not a good coding. at the end (even if it costs more lines) i split the field and text to two diffrent widgets.
maybe wrapping with some class may work, don't know.
thanks anyway :)


13 Eylül 2014 Cumartesi 00:24:06 UTC+3 tarihinde Justin Israel yazdı:
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.



--


Bests,
madoodia

--
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_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages