Hi all:
First off, I'd like to send a huge thanks to Chad and the pyMel team.
I started using pyMel after installing 2011 - what an incredible
effort you all have put forth - thanks so much.
Even the documentation is considerately written - I'm not a
professional coder, so I never quite understood what OOP meant until I
read Chad's explanation of OOP vs using procedures. I'm learning a
lot as I use it.
So I've started switching my coding to pyMel and I've run into an
error, probably very simple.
When I run a 'regular' python version of this script, it works, but I
get this error message when I run the pyMel version:
import demo_CommandCallbacks
demo_CommandCallbacks.buildWin()
# Error: NameError: file C:/Documents and Settings/Administrator/My
Documents/maya/2011-x64/scripts\demo_CommandCallbacks.py line 20:
global name 'window' is not defined #
line 20 is
if window(winName...
One other question:
My userSetup.py includes the line
from pymel.core import *
Do I need to include that line in my external scripts as well?
Thanks.
----------- CODE -------------------------------
from pymel import *
def buttonPressed3(name, *args): # Use * to insure that all args will
be passed
print ("pressed %s!" % name)
print "Button click returns a tuple with",len(args),"element(s)."
print "Args: %s" % (args)
print "First Element of Args: %s" % (args[0])
print "First Element of Args:", (args[0])
# lambda is like a one line function. We use it to absorb the args
passed by the button click, which we probably don't need.
def buildWin():
winName = 'pyMelTest1'
if window(winName, q=True, ex=True):
deleteUI(winName)
win = window(winName, t="pyMelTest1",wh=(300,150))
layout = columnLayout()
btn = button(l="Click Here Three", command = lambda *args:
buttonPressed3('dude', args) )
showWindow(win)
--
http://groups.google.com/group/python_inside_maya