Python in Maya

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2008   #1
Smile Python in Maya

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?...447192283e5.jpg


THNX MAX
 
Old 12 December 2008   #2
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!
 
Old 12 December 2008   #3
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!
__________________
my webfolio
 
Old 12 December 2008   #4
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!
 
Old 12 December 2008   #5
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:42 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.