wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.34k stars 517 forks source link

unable to detect wx.FocusEvent on wx.CheckBox with style wx.ALIGN_RIGHT #279

Open N46AN opened 7 years ago

N46AN commented 7 years ago

Basic info wxver - 3.0.3.dev2864+4fc5f9e gtk2 (phoenix) pyver - Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170118] on linux os-release - Debian GNU/Linux 9 (stretch)

Step to reproduce

  1. Run the following minimal example;
  2. Click the button and the checkbox alternatively, strings 'EVT_SET_FOCUS'/'EVT_KILL_FOCUS' are not printed.
  3. Remove ', style=wx.ALIGN_RIGHT' from self.cb_test and try the above steps again, strings are printed.
import wx

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent=None, title='test')
        self.pnl = wx.Panel(parent=self)

        self.btn = wx.Button(parent=self.pnl, label='test')

        self.cb_test = wx.CheckBox(parent=self.pnl, label='test', style=wx.ALIGN_RIGHT)
        self.cb_test.Bind(wx.EVT_SET_FOCUS, self.onSetFocus)
        self.cb_test.Bind(wx.EVT_KILL_FOCUS, self.onKillFocus)

        self.bs = wx.BoxSizer(wx.HORIZONTAL)
        self.bs.Add(self.btn)
        self.bs.Add(self.cb_test)
        self.pnl.SetSizer(self.bs)

    def onSetFocus(self, event):
        print('wxEVT_SET_FOCUS')

    def onKillFocus(self, event):
        print('wxEVT_KILL_FOCUS')

app = wx.App()
frame = MainFrame()
frame.Show(True)
app.MainLoop()
RobinD42 commented 7 years ago

This is likely a wxWidgets bug. Please create an issue for it at http://trac.wxwidgets.org/