473,388 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

wxPython button binding in XSI

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:
http://www.xsi-blog.com/archives/138\
I've copied the XSISubFrame exactly.

My specific app looks like this:

<code>
class jpFrame(XSISubFrame):
def __init__(self, parent, app):
XSISubFrame.__init__(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.MessageDialog(None, 'Are you sure?', 'Sure?')
if self.showModalDialog(dlg) == wx.ID_OK:
self.panel.onWindowClose()
XSISubFrame.OnClose(self, event)

class jpPanel(wx.Panel):
_runningInstances = []
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
self.frame = parent

selectAllButton = wx.Button(self, -1, "Select*GEO")
self.Bind(wx.EVT_BUTTON, self.selectAllGeo, selectAllButton)
selectHeirButton = wx.Button(self, -1, "Select Heir *GEO")
self.Bind(wx.EVT_BUTTON, self.selectHierGeo, selectHeirButton)

btn = wx.Button(self, -1, "Close")
self.Bind(wx.EVT_BUTTON, self.OnClose, btn)
self.Bind(wx.EVT_CLOSE, self.OnClose)

scenesFile = r"scenes.txt"
scenes = self.jpReadLines(scenesFile)
scenesList = wx.Choice(self, -1, choices=scenes)

deformButton = wx.Button(self, -1, "Deform Selected")
self.Bind(wx.EVT_BUTTON, self.applyDeformers, deformButton)

tID = wx.NewId()

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(selectAllButton, 0, wx.ALL)
sizer.Add(selectHeirButton, 0, wx.ALL)
sizer.Add(scenesList, 0, wx.ALL)
sizer.Add(deformButton, 0, wx.ALL)
sizer.Add(btn, 0, wx.ALL)
self.SetSizer(sizer)
self.Layout()
self.SetSize(sizer.GetSize())
self.SetAutoLayout(True)
self.frozen = False

self.Show(True)
jpPanel._runningInstances.append(self)
def selectAllGeo(self,event):
Application.LogMessage("This is a test: selectAllGeo")

Application.selectobj('*GEO')

def selectHierGeo(self, event):
Application.LogMessage("This is a test: selectHeirGeo")

Application.SelectTree()
model = Application.Selection[0]
Application.selectobj(model.FindChildren('*GEO'))

def jpReadLines(self, fileToRead):
lines = []
badLines = []

if os.path.exists(fileToRead) == False:
print "File Not Found"
else:
thisFile = file(fileToRead, "r+")
badLines = thisFile.readlines()
thisFile.close()
for i in range(0, len(badLines)):
lines.append(badLines[i].strip())
return lines

def applyDeformers(self, event):
Application.LogMessage("This is a test: applyDeformers")

path = self.poPath
scene = self.sceneList.get()
objs = Application.Selection
for thisObj in objs:
try:
Application.SetValue(str(thisObj) + ".polymsh.PO_XSI_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.LogMessage(thisPath)
Application.SetValue(str(thisObj) +
".polymsh.PO_XSI_Reader.FileName", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
except:
Application.ApplyOp("POXSI", str(thisObj), "siUnspecified",
"siPersistentOperation", "", 0)
Application.AddExpr((str(thisObj) +
".polymsh.PO_XSI_Reader.POTime"), "T", 1)
Application.SetValue(str(thisObj) + ".polymsh.PO_XSI_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.LogMessage(thisPath)
Application.SetValue(str(thisObj) +
".polymsh.PO_XSI_Reader.FileName", (path + os.sep + scene + os.sep +
str(splitObj[0]) + os.sep + str(splitObj[-1]) + ".mdd"), "")
def onWindowClose(self):
jpPanel._runningInstances.remove(self)

def OnClose(self, evt):
"""Event handler for the button click."""
self.frame.Close()

jpFrame.create()
</code>

Mar 1 '07 #1
0 1268

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rick Muller | last post by:
I have a problem that I would like to get some advice on from other Pythonistas. I currently manage a (soon to be) open source project for displaying molecular graphics for a variety of different...
7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
19
by: Grant Edwards | last post by:
I've decided to learn wxPython, and I'm afraid I just don't grok the whole "id" thing where you have to pull unique integers out of your, er, the air and then use those to refer to objects: ...
1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.2 release of wxPython is now available for download at http://wxpython.org/download.php. This is a mostly bug fix release and takes care of several "unfortunate...
3
by: swbi | last post by:
This is a problem faced by one of my friends. I have NO knowledge of Python but am just eager to help him. He created a button using Python 2.4 and used event bindings using the id for the button...
7
by: Erik Lind | last post by:
I'd appreciate any pointer on a simple way to tell within an event handler where the event came from. I want to have "while" condition in a handler to stop or change processing if an event occurs...
16
by: Andrea Gavana | last post by:
Hi Diez & All, Do you mind explaining "why" you find it *buttugly*? I am asking just out of curiosity, obviously. I am so biased towards wxPython that I won't make any comment on this thread...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.