Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:49:48+00:00 2026-06-07T11:49:48+00:00

After going through every possible resources I came to conclusion that I need an

  • 0

After going through every possible resources I came to conclusion that I need an urgent help to pass global variables from a function to others inside a Module in Python.

Actually I am writing a small UI in Autodesk Maya2010, here is a brief about the problem.

In the following code I have got two Module Level Global Variables, I am assigning values to them inside a function. Now if I pass these variables directly(i.e. without converting the function call and assigning it as a string) then the code works fine, however since the Command Flag of the Button Function only allows a string or a function name hence I am stuck with this way of calling the function.

The result which I get is :

temp_var=None

a_Window=None

which I have got no idea about.

Can anyone point down what exactly is happening when I use the string value as function call?

**The sample code**:


import maya.cmds;
temp_var=None;
a_Window=None;
def im_PrimaryFunc():
    imSecondary_func();

def imSecondary_func():
    global a_Window;
    global temp_var;
    a_Window=maya.cmds.window(title="Something");
    a_layout=maya.cmds.columnLayout(adj=1,rs=10);
    temp_var=maya.cmds.createNode("polySphere");
    func_call="a_calledFunc(a_Window,temp_var)";
    maya.cmds.button(label="call_aFunc",align="center",command=func_call);
    maya.cmds.showWindow(a_Window);

def a_calledFunc(arg00,arg01):
    print(arg00);
    print(arg01);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:49:50+00:00Added an answer on June 7, 2026 at 11:49 am

    Try this code

    import maya.cmds
    from functools import partial
    temp_var=None
    a_Window=None
    def im_PrimaryFunc():
        imSecondary_func()
    
    def imSecondary_func():
        global a_Window
        global temp_var
        a_Window=maya.cmds.window(title="Something")
        a_layout=maya.cmds.columnLayout(adj=1,rs=10)
        temp_var=maya.cmds.createNode("polySphere")
        maya.cmds.button(label="call_aFunc",align="center",command = partial(a_calledFunc,temp_var, a_Window))
        maya.cmds.showWindow(a_Window)
    
    def a_calledFunc(arg00,arg01, part):
        print(arg00)
        print(arg01)
    
    im_PrimaryFunc()
    

    Remember that you are writing python code so there is no need to add ; in your code 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After going through the effort of finally purging distro ruby packages from my Ubuntu
I am new to backbone and trying out my first app after going through
Something is puzzling me, after going through my app with instruments, it is a
After searching online and going through past stackoverflow posts for a suitable implementation for
What is the best way to name variables which contain multiple words? After going
After going through so many documents and online content like: http://stackoverflow.com/questions/4066167/sencha-touch-or-jquery-mobile http://stackoverflow.com/questions/5093691/sencha-touch-vs-jqtouch-vs-gwt-mobile-vs-xui-vs-jquery-mobile-vs http://www.quora.com/Were-deciding-between-jQuery-Mobile-currently-in-alpha-and-Sencha-Touch-What-are-the-pros-and-cons-for-each http://interfacethis.com/2011/adventures-in-html5-part-one/
I am using Lemonstand (an e-commerce CMS) and after going live with our site
Well looks too simple a question to be asked but i asked after going
Initially I had designed this flash based navigation menu for my website, after going
In my application, I present a modal view with a navigation controller. After going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.