I have create some custom dialogs in wxpython that I am very happy with.  I can execute pretty much anything I want based on user interaction and then once "OK" is selected collect the information from whatever functions I have run.
What I am wondering is there a way to execute a final function at the time "OK" is selected.  I do not have any sample code because I am not sure where to start and the demo does not do this, if it did my question would be answered by that.
So lets say that in the dialog I have calculated A and B and when "OK" is selected I want to execute C = str(A) + "whatever" + str(B)
So that upon exit I can dlg.C.GetValue() =
Just create self.C in your custom dialog's __init__ method. Then bind your OK button to a handler and update it as you mentioned. Then you should be able to get its value just as you stated: value = dlg.C.GetValue().
One thing to keep in mind is that when you create the OK button, do not set its id to wx.OK. If you do, it may not call your custom event handler as wx.OK is a special id that has a special default handler.
WXPYTHON CUSTOM DIALOG