Reputation: 6967
I'm trying to write a script that will simple toggle the graph Editor on and off in Maya.
Trouble is the windows aren't called by the same thing they are named and I'm not sure how to determine if the current window exists. Also a little confused as to what constitutes a panel and a window but we'll just put that on a back burner for now.
My question is how to determine if the desired window exists and is open or not?
Here's what I have so far, code fans:
import maya.cmds as cmds
myWin = "graphEditor"
for panel in cmds.getPanel(sty = myWin):
# if closed then open
if (cmds.window(panel, exists=True)): // not working :(
print str(myWin) + " is now closed."
cmds.window( panel, e = True, visible = False )
else:
print str(myWin) + " is now open."
cmds.scriptedPanel(panel, e = True, to = True)
Upvotes: 0
Views: 1171
Reputation: 2512
you can use the command below to know if it is open :
grphEditor = cmds.getPanel(scriptType="graphEditor") or []
test = cmds.scriptedPanel(grphEditor, q=True, control=True)
if is returning something else than '', it means it is opened
Upvotes: 1