Python Forum
how to pass arguments between pythons scripts?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to pass arguments between pythons scripts?
#1
Hello, everybody,
I'm new in python and i'm trying to pass arguments between different scripts but they only update one way:
i'm calling the first script in maya with a shelf in maya like this:

try:
        myPM.close()
except:pass
import sys
sys.path.append("C:/Users/manue/Desktop/test")
import UiMayaTest as SBIRP
reload(SBIRP)
myPM = SBIRP.createUI()
this called script 'UiMayaTest.py' is a simple window with an intField entry and a button:

import sys
import maya.cmds as cmds
from functools import partial

def buttonPressed(episode, *args):
    passValue(episode, *args)
    print '============== buttonPressed ================'
    print 'EpisodeName ', EpisodeName

    Var = ''
    import UiMayaTestFunction
    Var = UiMayaTestFunction.FindVarFunc(EpisodeName,Var)
    print 'Var : ',Var

def createUI(): 
    myWindow = "SomeWindow"
    if cmds.window(myWindow,ex=True):
        cmds.deleteUI(myWindow)
    cmds.window(myWindow)
    cmds.columnLayout( adjustableColumn=True )
    cmds.text( label='Episode:  ', align='left' )
    episode = cmds.intField( "Episode", minValue = 100, maxValue = 1000, value =100)
    cmds.button(l="Open Last LIT scene", w=150, h=30, command=partial(buttonPressed,episode))
    cmds.setParent("..")
    cmds.showWindow()

def passValue(episode, *args):
    global EpisodeName
    EpisodeName = `cmds.intField( episode, query = True, value = True)
`

and the script called by it is called 'UiMayaTestFunction.py' and just return a variable called Var:

def FindVarFunc(EpisodeName, Var):
    print '============== FindVarFunc ================'
    print 'EpisodeName:' , EpisodeName 
    Var = 'Hello world'
    print 'Var: ',Var
    return Var
the variable 'EpisodeName' from UiMayaTest to UiMayaTestFunction is well updated each time i press the button,
but if i change the variable Var = 'Hello world' in UiMayaTestFunction by for example Var = 'Gnnn', it doesn't update it,
i've got always the same print or 'Var'... 'Hello world'
Thanks by advance for any help...
Reply


Messages In This Thread
how to pass arguments between pythons scripts? - by electricDesire - Oct-11-2020, 10:21 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to pass encrypted pass to pyodbc script tester_V 0 889 Jul-27-2023, 12:40 AM
Last Post: tester_V
  Possible to dynamically pass arguments to a function? grimm1111 2 2,222 Feb-21-2021, 05:57 AM
Last Post: deanhystad
  Why Pass Functions as arguments? muzikman 14 5,774 Jan-18-2021, 12:08 PM
Last Post: Serafim
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,581 Sep-07-2020, 08:02 AM
Last Post: perfringo
  How to pass multiple arguments into function Mekala 4 2,481 Jul-11-2020, 07:03 AM
Last Post: Mekala
  Pass Arguments to Function phillyfa 2 2,051 Mar-27-2020, 12:05 PM
Last Post: phillyfa
  Pass by reference vs Pass by value leodavinci1990 1 2,231 Nov-20-2019, 02:05 AM
Last Post: jefsummers
  merging lists, dedup and keeping order, in older pythons Skaperen 3 3,192 Oct-19-2018, 01:30 AM
Last Post: ODIS
  How to pass arguments to popen? zBernie 3 12,946 Jul-09-2018, 01:26 AM
Last Post: zBernie
  # of Positional arguments to pass for creating an object? burvil 2 3,865 Sep-09-2017, 06:43 PM
Last Post: burvil

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020