View Full Version : Communicate btween UI Windows?
03-02-2011, 05:55 AM
Say we have a window called winA, which launches a scriptJob called winAJob.
I can kill the scriptjob from the SE with:
cmds.scriptJob( kill=winA.winAJob, force=True)
Now say I have winB, and I want to kill winA.winAJob from a command in winB - how do I address winA's scriptJob?
03-03-2011, 02:11 PM
could you have a hidden int feild and store the job number in there then query that?
03-03-2011, 02:29 PM
I think the problem is that the windows need to told to go up to the root namespace, something like:
But I don't know how to do that.
03-06-2011, 03:36 PM
scriptJobs have no namespaces, they are accessible from everywhere trough there unique id, which is returned from the creation command. So if you have s'thing like that:
int $jobid = `scriptJob -ct "cond" "command"`;
you can later kill the job with from any control:
scriptJob -kill $jobId;
If you attach the scriptJob to a UI control via "-parent" flag, then it will be killed when you close the UI.
So for your case I would use probably fileInfo - this way you will have this id stored with maya's scene file an can access it whenever you like.
03-07-2011, 10:07 PM
Thanks Nikolay. Parenting the scriptjob solved the problem. I don't need to store the number in the scene, but the fileInfo is a useful thing to know about.
However, I see that if a var is created in one window, it cannot be directly accessed from another - or even from the root sometimes. Same for a process. For example, I have a UI window that I use to execute commonly used py scripts. If launch a script from within that window, and then try to reload it from the SE, I get an error.
IE, from pixL_pyScripts.py, I execute:
module = __import__('pixL_addParents')
reload (module) # Works from w/in the UI
//Then from the SE:
reload(reloadpixL_addParents) # Fails from SE
# NameError: name 'pixL_addParents' is not defined #
However if pixL_addParents is imported via the SE, the reload function will work all the time after that.
03-07-2011, 10:07 PM
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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.