View Full Version : function declated at global level not found

09 September 2012, 04:15 AM
I have two problems i couldnt figure out why is it happening..

I have function ImgplaneDone() declared at global level

but when I try to call the function from within the class like this

self.donebtn=cmds.button(label="Done", command='ImgplaneDone(pathdict)',align='right')
Even though the ImgplaneDone() is at the same level as main() function is (not inside main function)
I get error # NameError: name 'ImgplaneDone' is not defined # , the weirdest thing is i only get error if I run the script like this

import setimgpln

but if i load it in the script editor and press ctrl + enter then evrything works fine.,...

the second problem I couldnt understand why is it happening I have created an instance of the class that contains GUI framework and call the function create from main() function,

Now even though I have this code at the end
if __name__ == '__main__':

i still have to make a call like setimgpln.main() from shelf button or command line at bottom instead of just setimgpln.

CGTalk Moderation
09 September 2012, 04:15 AM
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.