Hi,
I'm a newbie to wxPython.
I'm trying to enable/disable TextCtrl objects using the status of a
CheckBox object.
However, the binding of TextCtrl object to EVT_CHECKBOX does not work.
The following is the sample code.
Is this a bug or not supposed to work?
Thanks for help in advance.
···
============================================================
import wx
def OnPanelTest(evt):
print evt.GetEventObject().GetLabel(),
print 'EVT_CHECBOX is bound to a Panel object'
evt.Skip()
def OnTextCtrlTest(evt):
print evt.GetEventObject().GetLabel(),
print 'EVT_CHECBOX is bound to a TextCtrl object'
evt.Skip()
app = wx.PySimpleApp()
frm = wx.Frame(None,-1,"Test")
panel = wx.Panel(frm)
sizer = wx.BoxSizer(wx.HORIZONTAL)
chbox = wx.CheckBox(panel, -1, 'CheckBox')
sizer.Add(chbox, 0, wx.ALL, 10)
ctrl = wx.TextCtrl(panel, -1, 'TextCtrl')
sizer.Add(ctrl, 0, wx.ALL, 10)
panel.Bind(wx.EVT_CHECKBOX, OnPanelTest, chbox) # working
ctrl.Bind(wx.EVT_CHECKBOX, OnTextCtrlTest, chbox) # not working
panel.SetAutoLayout(True)
panel.SetSizer(sizer)
sizer.Fit(panel)
sizer.SetSizeHints(panel)
panel.Layout()
app.SetTopWindow(frm)
frm.Show()
app.MainLoop()