I feel like an idiot. I've been struggling with this for 4 days. I can
make a window but I can't seem to close them. I think I've narrowed
down the problem being with my button event bindings. They don't seem
to take. But I don't get any errors either. So am I missing something?
Any help would be appreciated. Thanks in advance.
I'm building a tool in XSI 6.0 based on this:
I've copied the XSISubFrame exactly.
My specific app looks like this:
<code>
class jpFrame(XSISubF rame):
def __init__(self, parent, app):
XSISubFrame.__i nit__(self, parent, app, -1, 'jpPointOven',
size=(100, 140))
self.panel = jpPanel(self)
def OnClose(self, event):
"""
This method is bound by XSISubFrame to the EVT_CLOSE event.
It shows a modal dialog before closing.
Notice the win32gui hack to disable the XSI top-level window during
the modal time.
"""
dlg = wx.MessageDialo g(None, 'Are you sure?', 'Sure?')
if self.showModalD ialog(dlg) == wx.ID_OK:
self.panel.onWi ndowClose()
XSISubFrame.OnC lose(self, event)
class jpPanel(wx.Pane l):
_runningInstanc es = []
def __init__(self, parent):
wx.Panel.__init __(self, parent, -1)
self.frame = parent
selectAllButton = wx.Button(self, -1, "Select*GEO ")
self.Bind(wx.EV T_BUTTON, self.selectAllG eo, selectAllButton )
selectHeirButto n = wx.Button(self, -1, "Select Heir *GEO")
self.Bind(wx.EV T_BUTTON, self.selectHier Geo, selectHeirButto n)
btn = wx.Button(self, -1, "Close")
self.Bind(wx.EV T_BUTTON, self.OnClose, btn)
self.Bind(wx.EV T_CLOSE, self.OnClose)
scenesFile = r"scenes.txt "
scenes = self.jpReadLine s(scenesFile)
scenesList = wx.Choice(self, -1, choices=scenes)
deformButton = wx.Button(self, -1, "Deform Selected")
self.Bind(wx.EV T_BUTTON, self.applyDefor mers, deformButton)
tID = wx.NewId()
sizer = wx.BoxSizer(wx. VERTICAL)
sizer.Add(selec tAllButton, 0, wx.ALL)
sizer.Add(selec tHeirButton, 0, wx.ALL)
sizer.Add(scene sList, 0, wx.ALL)
sizer.Add(defor mButton, 0, wx.ALL)
sizer.Add(btn, 0, wx.ALL)
self.SetSizer(s izer)
self.Layout()
self.SetSize(si zer.GetSize())
self.SetAutoLay out(True)
self.frozen = False
self.Show(True)
jpPanel._runnin gInstances.appe nd(self)
def selectAllGeo(se lf,event):
Application.Log Message("This is a test: selectAllGeo")
Application.sel ectobj('*GEO')
def selectHierGeo(s elf, event):
Application.Log Message("This is a test: selectHeirGeo")
Application.Sel ectTree()
model = Application.Sel ection[0]
Application.sel ectobj(model.Fi ndChildren('*GE O'))
def jpReadLines(sel f, fileToRead):
lines = []
badLines = []
if os.path.exists( fileToRead) == False:
print "File Not Found"
else:
thisFile = file(fileToRead , "r+")
badLines = thisFile.readli nes()
thisFile.close( )
for i in range(0, len(badLines)):
lines.append(ba dLines[i].strip())
return lines
def applyDeformers( self, event):
Application.Log Message("This is a test: applyDeformers" )
path = self.poPath
scene = self.sceneList. get()
objs = Application.Sel ection
for thisObj in objs:
try:
Application.Set Value(str(thisO bj) + ".polymsh.PO_XS I_Reader.Mute",
0, "")
splitObj = re.split("\.", str(thisObj))
thisPath = (path + os.sep + scene + os.sep + str(splitObj[0]) +
os.sep + str(splitObj[-1]) + ".mdd")
Application.Log Message(thisPat h)
Application.Set Value(str(thisO bj) +
".polymsh.PO_XS I_Reader.FileNa me", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
except:
Application.App lyOp("POXSI", str(thisObj), "siUnspecified" ,
"siPersistentOp eration", "", 0)
Application.Add Expr((str(thisO bj) +
".polymsh.PO_XS I_Reader.POTime "), "T", 1)
Application.Set Value(str(thisO bj) + ".polymsh.PO_XS I_Reader.Mute",
0, "")
splitObj = re.split("\.", str(thisObj))
thisPath = (path + os.sep + scene + os.sep + str(splitObj[0]) +
os.sep + str(splitObj[-1]) + ".mdd")
Application.Log Message(thisPat h)
Application.Set Value(str(thisO bj) +
".polymsh.PO_XS I_Reader.FileNa me", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
def onWindowClose(s elf):
jpPanel._runnin gInstances.remo ve(self)
def OnClose(self, evt):
"""Event handler for the button click."""
self.frame.Clos e()
jpFrame.create( )
</code>
make a window but I can't seem to close them. I think I've narrowed
down the problem being with my button event bindings. They don't seem
to take. But I don't get any errors either. So am I missing something?
Any help would be appreciated. Thanks in advance.
I'm building a tool in XSI 6.0 based on this:
I've copied the XSISubFrame exactly.
My specific app looks like this:
<code>
class jpFrame(XSISubF rame):
def __init__(self, parent, app):
XSISubFrame.__i nit__(self, parent, app, -1, 'jpPointOven',
size=(100, 140))
self.panel = jpPanel(self)
def OnClose(self, event):
"""
This method is bound by XSISubFrame to the EVT_CLOSE event.
It shows a modal dialog before closing.
Notice the win32gui hack to disable the XSI top-level window during
the modal time.
"""
dlg = wx.MessageDialo g(None, 'Are you sure?', 'Sure?')
if self.showModalD ialog(dlg) == wx.ID_OK:
self.panel.onWi ndowClose()
XSISubFrame.OnC lose(self, event)
class jpPanel(wx.Pane l):
_runningInstanc es = []
def __init__(self, parent):
wx.Panel.__init __(self, parent, -1)
self.frame = parent
selectAllButton = wx.Button(self, -1, "Select*GEO ")
self.Bind(wx.EV T_BUTTON, self.selectAllG eo, selectAllButton )
selectHeirButto n = wx.Button(self, -1, "Select Heir *GEO")
self.Bind(wx.EV T_BUTTON, self.selectHier Geo, selectHeirButto n)
btn = wx.Button(self, -1, "Close")
self.Bind(wx.EV T_BUTTON, self.OnClose, btn)
self.Bind(wx.EV T_CLOSE, self.OnClose)
scenesFile = r"scenes.txt "
scenes = self.jpReadLine s(scenesFile)
scenesList = wx.Choice(self, -1, choices=scenes)
deformButton = wx.Button(self, -1, "Deform Selected")
self.Bind(wx.EV T_BUTTON, self.applyDefor mers, deformButton)
tID = wx.NewId()
sizer = wx.BoxSizer(wx. VERTICAL)
sizer.Add(selec tAllButton, 0, wx.ALL)
sizer.Add(selec tHeirButton, 0, wx.ALL)
sizer.Add(scene sList, 0, wx.ALL)
sizer.Add(defor mButton, 0, wx.ALL)
sizer.Add(btn, 0, wx.ALL)
self.SetSizer(s izer)
self.Layout()
self.SetSize(si zer.GetSize())
self.SetAutoLay out(True)
self.frozen = False
self.Show(True)
jpPanel._runnin gInstances.appe nd(self)
def selectAllGeo(se lf,event):
Application.Log Message("This is a test: selectAllGeo")
Application.sel ectobj('*GEO')
def selectHierGeo(s elf, event):
Application.Log Message("This is a test: selectHeirGeo")
Application.Sel ectTree()
model = Application.Sel ection[0]
Application.sel ectobj(model.Fi ndChildren('*GE O'))
def jpReadLines(sel f, fileToRead):
lines = []
badLines = []
if os.path.exists( fileToRead) == False:
print "File Not Found"
else:
thisFile = file(fileToRead , "r+")
badLines = thisFile.readli nes()
thisFile.close( )
for i in range(0, len(badLines)):
lines.append(ba dLines[i].strip())
return lines
def applyDeformers( self, event):
Application.Log Message("This is a test: applyDeformers" )
path = self.poPath
scene = self.sceneList. get()
objs = Application.Sel ection
for thisObj in objs:
try:
Application.Set Value(str(thisO bj) + ".polymsh.PO_XS I_Reader.Mute",
0, "")
splitObj = re.split("\.", str(thisObj))
thisPath = (path + os.sep + scene + os.sep + str(splitObj[0]) +
os.sep + str(splitObj[-1]) + ".mdd")
Application.Log Message(thisPat h)
Application.Set Value(str(thisO bj) +
".polymsh.PO_XS I_Reader.FileNa me", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
except:
Application.App lyOp("POXSI", str(thisObj), "siUnspecified" ,
"siPersistentOp eration", "", 0)
Application.Add Expr((str(thisO bj) +
".polymsh.PO_XS I_Reader.POTime "), "T", 1)
Application.Set Value(str(thisO bj) + ".polymsh.PO_XS I_Reader.Mute",
0, "")
splitObj = re.split("\.", str(thisObj))
thisPath = (path + os.sep + scene + os.sep + str(splitObj[0]) +
os.sep + str(splitObj[-1]) + ".mdd")
Application.Log Message(thisPat h)
Application.Set Value(str(thisO bj) +
".polymsh.PO_XS I_Reader.FileNa me", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
def onWindowClose(s elf):
jpPanel._runnin gInstances.remo ve(self)
def OnClose(self, evt):
"""Event handler for the button click."""
self.frame.Clos e()
jpFrame.create( )
</code>