event handling

hey guys i have a python program which displays a dialog box and
calls a module in another python program.The problem i'm facing is
that the control gets stuck in the event handler in the other module
and does not return control to the calling program.Is there any
command to exit the event handler?if i use sys.exit in the event
handler the entire program terminates whereas i want only the module
to terminate.
hope some one can help me out on this one.
thanks in advance,
Robin

What is going on in the other module? If it is calling ShowModal for a dialog then that is the way it is supposed to work, it will block there (while still processing events) until the dialog is closed with the Enter or ESC key, or something else calls EndModal.

OTOH, if that module is creating its own wx.App object and calling MainLoop then that is a major problem and should not be done. You should reorganize the code in the other module such that the wx.App is not created if the module is imported rather than executed, and then you can import and use the classes in that module like normal from your main module.

If that doesn't help you then please make a runnable, small as possible, sample application that demonstrates the problem. MakingSampleApps - wxPyWiki

···

On 3/15/11 8:16 AM, robin wrote:

hey guys i have a python program which displays a dialog box and
calls a module in another python program.The problem i'm facing is
that the control gets stuck in the event handler in the other module
and does not return control to the calling program.Is there any
command to exit the event handler?if i use sys.exit in the event
handler the entire program terminates whereas i want only the module
to terminate.

--
Robin Dunn
Software Craftsman

EndModal was what I was looking for.It helped me return control to the
calling program.thanks a lot for your help

···

On Mar 15, 9:37 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 3/15/11 8:16 AM, robin wrote:

> hey guys i have a python program which displays a dialog box and
> calls a module in another python program.The problem i'm facing is
> that the control gets stuck in the event handler in the other module
> and does not return control to the calling program.Is there any
> command to exit the event handler?if i use sys.exit in the event
> handler the entire program terminates whereas i want only the module
> to terminate.

What is going on in the other module? If it is calling ShowModal for a
dialog then that is the way it is supposed to work, it will block there
(while still processing events) until the dialog is closed with the
Enter or ESC key, or something else calls EndModal.

OTOH, if that module is creating its own wx.App object and calling
MainLoop then that is a major problem and should not be done. You
should reorganize the code in the other module such that the wx.App is
not created if the module is imported rather than executed, and then you
can import and use the classes in that module like normal from your main
module.

If that doesn't help you then please make a runnable, small as possible,
sample application that demonstrates the problem.MakingSampleApps - wxPyWiki

--
Robin Dunn
Software Craftsmanhttp://wxPython.org