Overridden OnOK not called.

Hi,

I have a class which is derived from wx.Dialog in this
class I implemented an OnOK function.
The Dialog also has a button with an ID of wx.ID_OK.
But the OnOk function isn't called when I click on the button.
As far as I can tell OnOk should be called.
Anyone have an Idea why not?

Sample script attached.
WinXP, 2.5.1.5, with python 2.3.2

Regards
     Adi

test.py (1.29 KB)

Hello,

I have no idea. I have the same problem on Windows 2000. Just bind the
function to the button.

M. Vernier

···

-----Original Message-----
From: Adi Sieker [mailto:ml@sieker.info]
Sent: Thursday, May 13, 2004 9:52 PM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] Overridden OnOK not called.

Hi,

I have a class which is derived from wx.Dialog in this
class I implemented an OnOK function.
The Dialog also has a button with an ID of wx.ID_OK.
But the OnOk function isn't called when I click on the button. As far as I
can tell OnOk should be called. Anyone have an Idea why not?

Sample script attached.
WinXP, 2.5.1.5, with python 2.3.2

Regards
     Adi

Adi Sieker wrote:

Hi,

I have a class which is derived from wx.Dialog in this
class I implemented an OnOK function.
The Dialog also has a button with an ID of wx.ID_OK.
But the OnOk function isn't called when I click on the button.
As far as I can tell OnOk should be called.
Anyone have an Idea why not?

It takes extra work and runtime overhead to allow C++ methods to be overridable in Python derived classes, so it is only done when it is really needed to fullfil the design of the class. In this case however you can just bind EVT_BUTTON to your method.

···

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

Robin Dunn wrote:

Adi Sieker wrote:

Hi,

I have a class which is derived from wx.Dialog in this
class I implemented an OnOK function.
The Dialog also has a button with an ID of wx.ID_OK.
But the OnOk function isn't called when I click on the button.
As far as I can tell OnOk should be called.
Anyone have an Idea why not?

It takes extra work and runtime overhead to allow C++ methods to be overridable in Python derived classes, so it is only done when it is really needed to fullfil the design of the class.

Ah ok. No Problem.
Shouldn't this be mentioned in the wxWidgets docs. As a wxPYthon specific thing.

> In this case however

you can just bind EVT_BUTTON to your method.

That's what I was going todo.

Regards
    Adi