I think the primary suggestion about ensuring your code is all within
functions and not executing at the module level is the real focus. And then
your shelf button does the import and calls the entry point function.

But I did just notice something that may help correct your issue. Instead
of using a string reference to the name of your button callback, you should
switch it to use the actual callable:

>From this:

mc.button(l="Press to print the value of the checkbox below", w=300, h=100,
          command = 'printIt()' )

​
To this:

mc.button(l="Press to print the value of the checkbox below", w=300, h=100,
          command=printIt )

​
That way your button doesn't have to try and look up your printIt()
function in a particular scope (or global scope). It just uses the callable
object directly.

- Justin




On Wed, Jul 16, 2014 at 10:53 AM, Gabriele Bartoli <[email protected]
> wrote:

> Hi Reyan.
>
> Thanks, I'll give it a shot and see what happens. I must say that I don't
> understand how using a Class might help me. If you'd like to explain
> further, I would really appreciate it!
>
> Cheers!
>
>
> On Tuesday, 15 July 2014 22:03:14 UTC+2, Reyan wrote:
>>
>> Hi, try to put def printIt() before the interface creation.
>> I'ts the first and simplest way if you don't want put all in a class
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/bd96c3b7-9fe1-4f38-b7fb-8e4506792af2%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/bd96c3b7-9fe1-4f38-b7fb-8e4506792af2%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA349BxhVeEWouyswS7%3Dzs9M3d4sXjpxe-EKuo_Vadf_Mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to