Just reported this bug (#702126
http://sourceforge.net/tracker/index.php?func=detail&aid=702126&group_id=986
3&atid=109863) which seems to boil down to a wxCheckListBox crashing if the
user presses spacebar when no entry in the box is selected.
Anyone know of an event I can catch to check for this condition and avoid
the crash? Sample code showing the crash is provided with the bug report.
Thanks in advance
S.
Robin
March 12, 2003, 7:42pm
2
Sean Slattery wrote:
Just reported this bug (#702126
http://sourceforge.net/tracker/index.php?func=detail&aid=702126&group_id=986
3&atid=109863) which seems to boil down to a wxCheckListBox crashing if the
user presses spacebar when no entry in the box is selected.
Anyone know of an event I can catch to check for this condition and avoid
the crash? Sample code showing the crash is provided with the bug report.
You can catch EVT_KEY_DOWN of the check list box and check it there. Just be sure to call evt.Skip so the CLB can still get the event. Here is you sample with a workaround added:
from wxPython.wx import *
class MyApp(wxApp):
def OnInit(self):
frame = wxFrame(NULL, 1, "CLB Test", size=(200,200))
clb = wxCheckListBox(frame, -1, choices=[])
EVT_KEY_DOWN(clb, self.OnKeyDown)
clb.Append("Foo")
frame.Show(true)
self.SetTopWindow(frame)
return True
def OnKeyDown(self, evt):
clb = evt.GetEventObject()
if clb.GetSelection() != -1:
evt.Skip()
if __name__ == "__main__":
app = MyApp(0)
app.MainLoop()
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!