scriptJob function does not work

scriptJob function does not work

Anonymous
Not applicable
1,065 Views
2 Replies
Message 1 of 3

scriptJob function does not work

Anonymous
Not applicable

Hi, everyone!

 

I'm programming a plug-in that creates a new window. I'm calling the Maya API method "scriptJob" to delete my window and close the plug-in properly.

Here's my code, I don't know which is the problem:

 

import pymel.core as pm

win=pm.window(label="WindowExample")
pm.showWindow(win)

def closePlugin():
    pm.deleteUI(win, window=True)

pm.scriptJob(uiDeleted=[win, closePlugin], parent=(win))

Thanks in advance! 😄

0 Likes
Accepted solutions (1)
1,066 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

Hi,

I think you don't have to call a delete in your script job, because the script job is called when the window will be deleted, so you actually try to delete a deleted window. However the problem is the parent parameter. The closePlugin() method will be called (and a test print will be executed)  when I delete the parent parameter. Not sure which Maya version you are using but my window has no attribute "label", but "title".

 

 

import pymel.core as pm

def closePlugin():
    print("TEST")
    

win=pm.window(title="WindowExample")
pm.showWindow(win)
pm.scriptJob(uiDeleted=[win, closePlugin])
0 Likes
Message 3 of 3

Anonymous
Not applicable

Oh! I thought the method was called before the window was closed. Thanks, it was really helpful 🙂

0 Likes