Has Anyone Tried wxPython For Max OSX?
I'm running Python 2.5 on Mac OSX 10.3.9.
I downloaded
wxPython 2.8 - OSX - Unicode - 2.8.6.1 - Universal - Python 2.5.
When I run it, everything works fine. I can do lots of things like disable/enable widgets, select from a combo box, hide the window, select from the file menu, etc, etc...
However, when I try this code, I get a "Segmentation Fault" or "Bus Error". This does not happen on Windows. Any idea what's going on?
def findBallot(self, event):
self.checkBallotEntry(event)
# Initiate Search List
if self.lastImage == self.invalidImage:
searchFor = event.GetString()
matches = findClosest(searchFor, self.handler.ballotSeen)
if matches:
# hide stuff underneath
self.ballotType.Hide()
self.outputFile.Hide()
self.selectFile.Hide()
# remove the old search box
if self.searchResults:
self.searchResults.Destroy()
self.searchResults = None
matches.sort()
# show the new search box
self.searchResults = wx.ListBox(self.generalPanel, id=lazyID('search'), pos=wx.Point(75, 64), size=wx.Size(167, 75),
choices=[__LANG_SEARCH_RESULTS__%len(matches)] + matches, style=wx.LB_SINGLE)
self.Bind(wx.EVT_LISTBOX, self.selectSearch, self.searchResults)
def destroySearch(self):
self.searchResults.Destroy()
self.searchResults = None
self.ballotType.Show()
self.outputFile.Show()
self.selectFile.Show()
def selectSearch(self, event):
if event.GetSelection() != 0: # Can't pick the first result
searchChoice = event.GetString()
self.ballotList.SetValue(searchChoice)
self.ballotList.SetFocusFromKbd()
self.ballotList.SetInsertionPointEnd()
# End Search List
if self.searchResults:
self.destroySearch()
self.checkBallotEntry(None)
"findBallot" is called when a letter is typed. It toggles a search list if the entry is incorrect.
"destroySearch" destroys this search list once the entry is correct, or an item has been selected.
"selectSearch" is called when the user selects one of the search options.
The error happens after "selectSearch" is done. This makes little sense, because after "selectSearch" is done, no code is executed. The window remains idle, as a solitary cron task continues running every second afterwards. This task has always been executing, so this shouldn't be an issue. Nevertheless, the code is:
def handleGlitch(self, event):
# The win32api doesn't always tell us when the combobox's text changes, so check every second in case
self.checkBallotEntry(None)
event.Skip()
But "self.checkBallotEntry(None)" can't be the problem either, because it was succesfully called near the end of "selectSearch", which finished executing before the error occurred.
I can't show you any more code then this. I actually signed a non-disclosure agreement that stops me from even giving that much away... but whatever...
Edit : Probably important to note. I can still see the search list before the program stalls and crashes. This means it did not destroy the search list when it was supposed to. I think this is a good indicator of the error. What am I doing then that Mac OSX doesn't like? It was fine hiding/enabling other widgets. Maybe I'll look at the "destroy" attribute under Mac OSX. Do some testing there...