wx.lib.masked - exceptions with read only combobox

Hi,

I am running into three exceptions when setting a wx.lib.masked.combobox to wx.CB_READONLY and right clicking and selecting "Undo".

1. Attribute error on self._prevSelection, adding this to its init resolves that:
self._prevSelection = (-1, -1)

2. wx._core.PyAssertionError: C++ assertion "!HasFlag(wxCB_READONLY)" failed at ..\
..\src\msw\combobox.cpp(423) in wxComboBox::GetEditHWND(): read-only combobox do
esn't have any edit control

3. maskededit.py, line 3205, in _FindField
   raise IndexError('position %s out of range of control' % str(pos))

The attached patch fixes these for me.

Werner

maskedComboReadonly.patch (1.64 KB)

Hi,

Hi,

I am running into three exceptions when setting a wx.lib.masked.combobox to wx.CB_READONLY and right clicking and selecting "Undo".

1. Attribute error on self._prevSelection, adding this to its init resolves that:
self._prevSelection = (-1, -1)

2. wx._core.PyAssertionError: C++ assertion "!HasFlag(wxCB_READONLY)" failed at ..\
..\src\msw\combobox.cpp(423) in wxComboBox::GetEditHWND(): read-only combobox do
esn't have any edit control

3. maskededit.py, line 3205, in _FindField
  raise IndexError('position %s out of range of control' % str(pos))

The attached patch fixes these for me.

Found one more issue with combobox readonly, getting this one when I try to tab to next control:

app_cb.py, line 1030, in <module>
   app.MainLoop()
_core.py, line 8660, in MainLoop
   wx.PyApp.MainLoop(self)
_core.py, line 7952, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
combobox.py, line 588, in _OnKeyDownInComboBox
   self._keyhandlers[key](event)
maskededit.py, line 3804, in _OnChangeField
   field = self._FindField(sel_to)
maskededit.py, line 3205, in _FindField
   raise IndexError('position %s out of range of control' % str(pos))

I am not sure how to fix this one, as I can't get at the __readonly attribute in maskededit.py, so should I already catch it in _OnKeyDownInCombobox?

Comment in there indicates that it should be handled but it obviously is not, at least not in 2.9.4.

Werner

···

On 20/11/2012 19:43, Werner wrote:

Werner

Thanks.

···

On 11/20/12 10:43 AM, Werner wrote:

Hi,

I am running into three exceptions when setting a wx.lib.masked.combobox
to wx.CB_READONLY and right clicking and selecting "Undo".

1. Attribute error on self._prevSelection, adding this to its init
resolves that:
self._prevSelection = (-1, -1)

2. wx._core.PyAssertionError: C++ assertion "!HasFlag(wxCB_READONLY)"
failed at ..\
..\src\msw\combobox.cpp(423) in wxComboBox::GetEditHWND(): read-only
combobox do
esn't have any edit control

3. maskededit.py, line 3205, in _FindField
   raise IndexError('position %s out of range of control' % str(pos))

The attached patch fixes these for me.

--
Robin Dunn
Software Craftsman

I don't know. Perhaps it should just gracefully handle the IndexError in _OnChangeField?

···

On 11/21/12 8:50 AM, Werner wrote:

Hi,

Found one more issue with combobox readonly, getting this one when I try
to tab to next control:

app_cb.py, line 1030, in <module>
   app.MainLoop()
_core.py, line 8660, in MainLoop
   wx.PyApp.MainLoop(self)
_core.py, line 7952, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
combobox.py, line 588, in _OnKeyDownInComboBox
   self._keyhandlers[key](event)
maskededit.py, line 3804, in _OnChangeField
   field = self._FindField(sel_to)
maskededit.py, line 3205, in _FindField
   raise IndexError('position %s out of range of control' % str(pos))

I am not sure how to fix this one, as I can't get at the __readonly
attribute in maskededit.py, so should I already catch it in
_OnKeyDownInCombobox?

Comment in there indicates that it should be handled but it obviously is
not, at least not in 2.9.4.

--
Robin Dunn
Software Craftsman

Will give that a try and come back with a patch or other problem:-) .

Werner

···

On 21/11/2012 18:27, Robin Dunn wrote:

On 11/21/12 8:50 AM, Werner wrote:

Hi,

Found one more issue with combobox readonly, getting this one when I try
to tab to next control:

app_cb.py, line 1030, in <module>
   app.MainLoop()
_core.py, line 8660, in MainLoop
   wx.PyApp.MainLoop(self)
_core.py, line 7952, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
combobox.py, line 588, in _OnKeyDownInComboBox
   self._keyhandlers[key](event)
maskededit.py, line 3804, in _OnChangeField
   field = self._FindField(sel_to)
maskededit.py, line 3205, in _FindField
   raise IndexError('position %s out of range of control' % str(pos))

I am not sure how to fix this one, as I can't get at the __readonly
attribute in maskededit.py, so should I already catch it in
_OnKeyDownInCombobox?

Comment in there indicates that it should be handled but it obviously is
not, at least not in 2.9.4.

I don't know. Perhaps it should just gracefully handle the IndexError in _OnChangeField?

Hi Robin,

...

I don't know. Perhaps it should just gracefully handle the IndexError in _OnChangeField?

Attached my patch for the index error.

It also contains the change relating to the masked sizing with a change to better size controls of less then 10 characters.

Werner

maskedsizing2.patch (1.94 KB)

···

On 21/11/2012 18:27, Robin Dunn wrote: