Find the last window created in Maya?
<p>I was wondering if there is any way to find the name of the last window created in Maya, knowing that I can't add any information to the window itself before that... I checked in both the <code>cmds</code> and API but couldn't find anything. Maybe in PyQt but I don't know much about it.</p>

<p>I'm looking for any solution. Thanks</p>

<p>If you create a window with the <code>window</code> command, you'll get back the name of the window you just created:</p>

<pre><code>import maya.cmds as cmds
w = cmds.window()
c= cmds.columnLayout()

def who_am_i(*_):
    print "window is", w

b = cmds.button('push', c=who_am_i)
cmds.showWindow(w)
</code></pre>

<p>If for some reason you don't own the code that creates the window:</p>

<pre><code>existing_windows = set(cmds.lsUI(type = 'window'))
// make your window here
new_windows = list(set(cmds.lsUI(type = 'window') - existing_windows))
</code></pre>

python maya