Creating a custom UI inside Maya with python

MRAB python at
Mon Aug 9 17:10:26 CEST 2010

blur959 wrote:
> Hi, all, I wonder if my post is relevant here, but i will still post
> it anyway. I am working on creating a custom UI inside Maya and I
> encountered some problems. Firstly, I am trying to create a textfield
> button that creates a locator-shaped curve based on the coordinates
> the user keyed into the text field. However I got no idea how to go
> about doing it properly. I hope you guys could give me some help.
> Thanks. I attached my code below. My code isn't working though. I have
> this error, which says button2 is not defined. I got no clue on how
> else to debug.
> import maya.cmds as cmds
> def createMyLayout():
>     button2 = cmds.textFieldButtonGrp(label="LocatorCurve",
>                                         text="Please key in your
> coordinates",
>                                         changeCommand=edit_curve,
>                                         buttonLabel="Execute",
>                                         buttonCommand=locator_curve)

When you assign to a name in a function the target is by default local
to that function, so 'button2' is local to 'createMyLayout'. Add the

     global button2

to the function to make it visible to the rest of the module/file.

More information about the Python-list mailing list