Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Creating a custom UI inside Maya with python

Reply
Thread Tools

Creating a custom UI inside Maya with python

 
 
blur959
Guest
Posts: n/a
 
      08-09-2010
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():
window = cmds.window(widthHeight=(1000, 600), title="test",
resizeToFitChildren=1)
cmds.rowLayout("button1, button2, button3", numberOfColumns=5)

cmds.columnLayout(adjustableColumn=True, columnAlign="center",
rowSpacing=10)

button2 = cmds.textFieldButtonGrp(label="LocatorCurve",
text="Please key in your
coordinates",
changeCommand=edit_curve,
buttonLabel="Execute",
buttonCommand=locator_curve)


cmds.setParent(menu=True)

cmds.showWindow(window)

def locator_curve(*args):
# Coordinates of the locator-shaped curve.
crv = cmds.curve(degree=1,
point=[(1, 0, 0),
(-1, 0, 0),
(0, 0, 0),
(0, 1, 0),
(0, -1, 0),
(0, 0, 0),
(0, 0, 1),
(0, 0, -1),
(0, 0, 0)])


return crv

def edit_curve(*args):
parts = button2.split(",")
print parts
x = parts[0]
y = parts[1]
z = parts[2]


createMyLayout()


 
Reply With Quote
 
 
 
 
MRAB
Guest
Posts: n/a
 
      08-09-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():

[snip]
> button2 = cmds.textFieldButtonGrp(label="LocatorCurve",
> text="Please key in your
> coordinates",
> changeCommand=edit_curve,
> buttonLabel="Execute",
> buttonCommand=locator_curve)
>

[snip]

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
line:

global button2

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

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python & Blend or Maya pixellee Python 0 09-16-2007 03:49 AM
better Python IDE? Mimics Maya's script editor? warpcat Python 9 06-22-2006 09:11 PM
ANN: Python cgkit v2.0.0alpha6 & Maya Python package Matthias Baas Python 0 04-13-2006 08:16 PM
Maya API with Python? Brandon J. Van Every Python 3 04-26-2004 03:53 PM



Advertisments