event.Veto() takes away focus for wx.EVT_NOTEBOOK_PAGE_CHANGING on wx.GTK

Hi,

It is again me having a problem with the wx.EVT_NOTEBOOK_PAGE_CHANGING
event. My application has a notebook with several pages containing
several text controls. The text controls implement some kind of
validation. If the user tries to change the page, the current text
control having the focus gets validated. If there's an exception the an
apropriate message is shown to the user and the focus remains in the
offending control - no page change should take place.

Ok, so in the wx.EVT_NOTEBOOK_PAGE_CHANGING event I'll call the current
text controls' validator to do it's job. If an exception occured, an
event.Veto() follows, otherwise an event.Skip(). On wx.MSW and wx.Mac
this works perfectly fine. The focus remains in the textcontrol in case
of an exception. But on wx.GTK it does not. I event can't tell who is
having the focus.

Attached is a small sample app demonstrating the problem. To simulate an
failed validation just enter the value 100 into a text-control. If you
then change the page the text "Cannot change page, value is 100"
appears. But the focus disapears, and after entering another character
(like a, b, c...) the following error appears on stdout:

(python:26722): Gtk-CRITICAL **: gtk_widget_event: assertion
`WIDGET_REALIZED_FOR_EVENT (widget, event)' failed

(python:26722): Gtk-CRITICAL **: gtk_widget_event: assertion
`WIDGET_REALIZED_FOR_EVENT (widget, event)' failed

Is this a bug in wx.GTK ? Is there something I can do different to avoid
such a situation at all ? Again, the same demo-app works perfectly on
wx.MSW and wx.Mac ...

Thanks for your help,

Johannes

nbveto.py (2.2 KB)

···

--
BYTEWISE Software GmbH Tel +43 (5577) 89877-0
i.A. Johannes Vetter Fax +43 (5577) 89877-66
A-6890 Lustenau, Enga 2 http://www.bytewise.at
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wir bieten Installation und Support für Ubuntu: ein auf
GNU/Linux basierendes Softwaresystem für Arbeitsplatzrechner

Johannes Vetter wrote:

Hi,

It is again me having a problem with the wx.EVT_NOTEBOOK_PAGE_CHANGING
event. My application has a notebook with several pages containing
several text controls. The text controls implement some kind of
validation. If the user tries to change the page, the current text
control having the focus gets validated. If there's an exception the an
apropriate message is shown to the user and the focus remains in the
offending control - no page change should take place.

Ok, so in the wx.EVT_NOTEBOOK_PAGE_CHANGING event I'll call the current
text controls' validator to do it's job. If an exception occured, an
event.Veto() follows, otherwise an event.Skip(). On wx.MSW and wx.Mac
this works perfectly fine. The focus remains in the textcontrol in case
of an exception. But on wx.GTK it does not. I event can't tell who is
having the focus.

Looks like it is the panel on the 2nd page of the notebook. That seems kinda odd, perhaps could be considered a bug...

Attached is a small sample app demonstrating the problem. To simulate an
failed validation just enter the value 100 into a text-control. If you
then change the page the text "Cannot change page, value is 100"
appears. But the focus disapears,

Setting the focus back to the textctrl after a short delay seems to work for me.

             wx.FutureCall(100, text.SetFocus)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Looks like it is the panel on the 2nd page of the notebook. That
seems
kinda odd, perhaps could be considered a bug...

Shall I create a bug report ?

Setting the focus back to the textctrl after a short delay seems to
work
for me.

             wx.FutureCall(100, text.SetFocus)

I've tried something like this too, although I was using a wx.CallAfter
first. But using both, the wx.FutureCall as stated above or the
wx.CallAfter, it works fine for the first time the user clicks on the
tab of the notebook. The focus is sent back to the text control and i
could enter another value. But if I then click onto the tab again, the
same Gtk-Critical error appears. So the FutureCall/CallAfter addition
isn't a real help.

Thanks,
Johannes

···

Am Dienstag, den 11.04.2006, 22:55 -0700 schrieb Robin Dunn:

--
BYTEWISE Software GmbH Tel +43 (5577) 89877-0
i.A. Johannes Vetter Fax +43 (5577) 89877-66
A-6890 Lustenau, Enga 2 http://www.bytewise.at
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wir bieten Installation und Support für Ubuntu: ein auf
GNU/Linux basierendes Softwaresystem für Arbeitsplatzrechner

Johannes Vetter wrote:

Hi Robin,

Looks like it is the panel on the 2nd page of the notebook. That
seems kinda odd, perhaps could be considered a bug...

Shall I create a bug report ?

Yes. Use a category of "wxGTK specific".

···

Am Dienstag, den 11.04.2006, 22:55 -0700 schrieb Robin Dunn:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!