PDA

View Full Version : Python in Maya


fabiotoni
12-14-2008, 01:41 AM
Hi everyone! i need help with a problem that i cant solve, im new to python.

i need to create a window like this in maya using python. Anyone who knows how to to the regulators, the controls as you se in this pic below :

http://show.simpload.com/index.php?filename=121349447192283e5.jpg


THNX MAX

olson
12-16-2008, 01:10 AM
I'm just starting out with Python in Maya and haven't gotten that far yet. A guy I used to work with used Tkinter to make GUIs in Maya with Python. It sounds right from what I remember but I could be wrong, its been quite a few months and was just getting into Python itself at the time. Cheers!

kjaft
12-18-2008, 10:56 AM
No need to use any external UI kit. Thats very basic Maya UI stuff, please read the acording chapter in the Maya documentation (under the MEL section). The docs are concerned to mel, but the commands are the same in python.

BTW: This topic should be posted in the Maya Programming forum!

skeelogy
12-19-2008, 09:26 PM
Hi fabiotoni,

The following Python script should give you enough information to get you started:

import maya.cmds as mc

def createStoneFunction(*args):
print "do whatever that is necessary to create the stones here"

def createUi():
#check for existing window first
if mc.window("myWindow", exists=True):
mc.deleteUI("myWindow")

#create the window
mc.window("myWindow", title="Create stones", wh=(500, 270), sizeable=False)

#create layout
mc.frameLayout(marginHeight=5, marginWidth=5, labelVisible=False)
mc.columnLayout()

#create the size field
mc.text(label="Size")
mc.floatField(min=0, max=10, step=0.1, precision=1)
mc.separator(h=10, style="none")

#create the quantity field
mc.text(label="Qty")
mc.intField(min=0, max=100)
mc.separator(h=10, style="none")

#create the soft select fall off field/slider
mc.text(label="Soft Select Fall off")
mc.floatSliderGrp(field=True, minValue=0.0, maxValue=10.0, fieldMinValue=-0.0, fieldMaxValue=10.0, value=0)
mc.separator(h=10, style="none")

#create the roughness field/slider
mc.text(label="Roughness")
mc.floatSliderGrp(field=True, minValue=0.0, maxValue=10.0, fieldMinValue=-0.0, fieldMaxValue=10.0, value=0)
mc.separator(h=10, style="none")

#create the button
mc.button(label="Create Stones", command=createStoneFunction)

#finally, show the window
mc.showWindow("myWindow")

createUi()
If you need to know what other ui controls are available and their corresponding attributes, you may want to refer to the "Python Command Reference" under the Help menu, as kjaft has suggested.

And yes, you don't need to use Tkinter to do a UI like this in Maya, since Maya has its own set of functions to create UI. Tkinter is mostly used for creating UI outside of Maya, such as creating a window with buttons in Vista (or whatever OS you are running on).

Hope this helps!

CGTalk Moderation
12-19-2008, 09:26 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.