import os
import maya.cmds as cmds
class mypars_ts:
    def __init__(self):
        print "Hello\n"
    def testing(*args):
        print "Call Came\n"
    def window_lod (self):
        if cmds.window('ExampleWindow', exists=True):
            cmds.deleteUI('ExampleWindow', window=True)
        cmds.window( 'ExampleWindow' )
        cmds.columnLayout()
        cmds.text( label='Size and position the window before closing it.' )
        cmds.button( label='Close', command='testing' )
        cmds.showWindow( 'ExampleWindow' )
my_calls=mypars_ts()
my_calls.window_lod()

when ever i am trying to execute this code .. i am getting a error

# Error: name 'testing' is not defined
# Traceback (most recent call last):
#   File "<maya console>", line 1, in ?
# NameError: name 'testing' is not defined # 

but thts already defined

def testing(*args):
        print "Call Came\n"

where i am wrong :( can any one help please :(

Try
def testing(self, *args):

import os
import maya.cmds as cmds
class mypars_ts:
	def __init__(self):
		print "Hello\n"
	[B]def testing(self,*args):[/B]
		print "Call Came\n"
	def window_lod (self):
		if cmds.window('ExampleWindow', exists=True):
			cmds.deleteUI('ExampleWindow', window=True)
		cmds.window( 'ExampleWindow' )
		cmds.columnLayout()
		cmds.text( label='Size and position the window before closing it.' )
		cmds.button( label='Close', command=testing)
		cmds.showWindow( 'ExampleWindow' )
my_calls=mypars_ts()
my_calls.window_lod()

changed but no way its not working :(

fixed ....

import os
import re
import maya.cmds as cmds
class mypars_ts:
    def __init__(self):
        print "Hello\n"
#here self added
    def testing(self,*args):
        print "Call Came\n"
    def window_lod (self):
        if cmds.window('ExampleWindow', exists=True):
            cmds.deleteUI('ExampleWindow', window=True)
        cmds.window( 'ExampleWindow' )
        cmds.columnLayout()
        cmds.text( label='Size and position the window before closing it.' )
#here also
        cmds.button( label='Close', command=self.testing)
        cmds.showWindow( 'ExampleWindow' )
my_calls=mypars_ts()
my_calls.window_lod()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.