DEVILSAN
10-30-2012, 07:01 AM
filename is mywindow.py
class GUI(object):
def __init__(self):
self.widgets={}
self.winName="mywindow"
self.dock=""
self.v=mel.eval('getApplicationVersionAsFloat')
if self.v>= 2011: self.dock=True
else: self.dock=False
self.createUI(self.winName,self.dock)
def createUI(self,winName,dock):
"""
Creates dockable GUI if maya version above 2011
else creates flying window
"""
if self.dock:
if cmds.dockControl(self.winName,exists=True):
cmds.deleteUI(self.winName)
else:
if cmds.window(self.winName, exists=True):
cmds.deleteUI(self.winName)
print "WindowName: ", self.winName
print "state of dock: ", dock
# then I add some controls here
#Show the window
if self.dock:
cmds.dockControl(self.winName, area="left",allowedArea="left", content=self.widgets["window"])
else:
cmds.showWindow(self.widgets["window"])
I launch the above window using
import mywindow
reload( mywindow)
obj=mywindow.GUI()
this works fine on first run, but if i close it and try to reopen it i get error saying "mywindow is not unique"...
i guess i am doing something wrong while showing the window
class GUI(object):
def __init__(self):
self.widgets={}
self.winName="mywindow"
self.dock=""
self.v=mel.eval('getApplicationVersionAsFloat')
if self.v>= 2011: self.dock=True
else: self.dock=False
self.createUI(self.winName,self.dock)
def createUI(self,winName,dock):
"""
Creates dockable GUI if maya version above 2011
else creates flying window
"""
if self.dock:
if cmds.dockControl(self.winName,exists=True):
cmds.deleteUI(self.winName)
else:
if cmds.window(self.winName, exists=True):
cmds.deleteUI(self.winName)
print "WindowName: ", self.winName
print "state of dock: ", dock
# then I add some controls here
#Show the window
if self.dock:
cmds.dockControl(self.winName, area="left",allowedArea="left", content=self.widgets["window"])
else:
cmds.showWindow(self.widgets["window"])
I launch the above window using
import mywindow
reload( mywindow)
obj=mywindow.GUI()
this works fine on first run, but if i close it and try to reopen it i get error saying "mywindow is not unique"...
i guess i am doing something wrong while showing the window
