Hello,
I just discovered that when i bind focus events using EVT_SET_FOCUS and EVT_KILL_FOCUS on a wx.Choice, they do not work in wx 3.0 as they did in wx 2.8.
#!/usr/bin/env python
import wx
class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, title=“Test”)
panel = wx.Panel(frame)
choice = wx.Choice(panel, wx.NewId())
for label, value in (('One', 1), ('Two', 2)):
choice.Append(label, value)
field = wx.TextCtrl(panel, wx.NewId())
button = wx.Button(panel, wx.NewId(), label="Ok")
button.Bind(wx.EVT_BUTTON, self._on_button_click)
sizer = wx.BoxSizer(wx.HORIZONTAL)
for ctrl in (choice, field, button):
ctrl.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
ctrl.Bind(wx.EVT_KILL_FOCUS, self._on_kill_focus)
sizer.Add(ctrl, 0, wx.ALL, 5)
panel.SetSizer(sizer)
button.SetFocus()
frame.Show()
self.SetTopWindow(frame)
return True
def _on_set_focus(self, event):
print "Focus received:", event.GetEventObject()
event.Skip()
def _on_kill_focus(self, event):
print "Focus lost:", event.GetEventObject()
event.Skip()
def _on_button_click(self, event):
print "Button clicked."
event.Skip()
if name == ‘main’:
app = MyApp(redirect=False)
app.MainLoop()
``
This code emits the events for all controls (Choice, TextCtrl and Button) under 2.8 GTK Ubuntu, but under 3.0.1 GTK on Debian, the events are only emitted for TextCtrl and Button, not for the Choice. Just watch the output when tabbing through the form or when clicking by mouse.
Can someone else confirm this behavior? Does that look like a wx problem or wxPython’s? Any work arounds? Thank you for any ideas on this issue.