Application Not Terminating

Hello NGs,

   I probably found where the problem resides. As it is a wxPython+Matplotlib
issue, I will send the mail to both newsgroups.
The reason why my application does not terminates correctly on Windows 2000
while it terminates correctly on Windows XP does not depend on Windows version,
but on Matplotlib. I am not 100% sure, because here I only have (at the
moment) Windows XP, but I found a difference between 2 Matplotlib installations
I have.
On XP, I have Matplotlib 0.73 prerelease (that WAS a prerelease 1 months
ago, nearly), while on Windows 2000 I have Matplotlib 0.74.
Well, I am using the WXAgg backend. By looking at backend_wx.py in 0.73pre
(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

While on Matplotlib 0.74 (2000) they are NOT commented. Well, in my app
I don't need to initialize the wx.App() when calling plot/figure/Matplotlib
things, because my app has ALREADY initialized the wx.App().
If I use Matplotlib (without wxPython) I will just add:

import wx
MyApp = wx.PySimpleApp()

Before using any Matplotlib command.
Is there a reason why these lines were commented on 0.73pre and now they
are not? Robin/John, could it be that the reason for which my application
does not return under Windows 2000?

Thanks to you all.

Andrea.

Hello NG,

    It's incredible... after having found that my application correctly
terminates if I add the line:

self.MyTaskBarIcon.Destroy()

on Windows XP, I am UNABLE to terminate it on Windows 2000. The main

frame

is correctly destroyed, together with its children, but there is still

something

alive that prevents Python to correctly finish and returning to me the

control

of the DOS console.
The wxPython version is the same, the Python version is the same... the
only differences between the 2 PC is the Windows version (XP=work, 2000=don't
work) and the PC performances (XP=1GB RAM, 2000=528MB RAM).
I used Spy++ and its friends and, after my app terminates, on 2000 there
is still a window opened. This window has no class information, no particular
ID, only a size and position elements. There is no reason why the application
behavior should be different.
I don't even know which question I would formulate to you NG, it is a

pain

this continuous error-checking for a window/frame/panel that I didn't

create

···

andrea_gavana@...517... wrote:

and that wxPython thinks is still alive (only on Windows 2000).

If you can create a small sample that shows the problem I can run it
under the debugger to see if I can spot what's going on.

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

andrea_gavana@...517... wrote:

On XP, I have Matplotlib 0.73 prerelease (that WAS a prerelease 1 months
ago, nearly), while on Windows 2000 I have Matplotlib 0.74.
Well, I am using the WXAgg backend. By looking at backend_wx.py in 0.73pre
(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

While on Matplotlib 0.74 (2000) they are NOT commented. Well, in my app
I don't need to initialize the wx.App() when calling plot/figure/Matplotlib
things, because my app has ALREADY initialized the wx.App().
If I use Matplotlib (without wxPython) I will just add:

import wx
MyApp = wx.PySimpleApp()

Before using any Matplotlib command.
Is there a reason why these lines were commented on 0.73pre and now they
are not? Robin/John, could it be that the reason for which my application
does not return under Windows 2000?

Yes. Having two app objects can certainly cause problems, although I wouldn't have expected it to manifest this way. Probably what is happening is that when the spashscreen is closed it is being added to the pending delete list but then the new app is being created and the pending delete list is reinitialized and so the splash screen never gets destroyed for real so the app's MainLoop keeps running waiting for it to be destroyed.

To find out for sure you could try uncommenting those lines on your XP box and see if you then have the same problem.

···

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

Andrea,

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

I commented out these lines in backend_wx.py and moved them into
the show() function so that a wxPySimpleApp was not created when
importing backend_wx.py. This was done to avoid the problem you
saw, reported by someone else (I never saw this problem -- it
seems to also to depend on wxPython version??). A few days
later, John put it back the way it was (create wxPySimpleApp in
the main portion of backend_wx.py). If I remember correctly,
this was because *not* having these lines in the main section of
backend_wx.py caused problems for some people using pylab.

I cannot explain or defend why wxapp=wxPySimpleApp() should be
run when importing backend_wx.py: it makes no sense to me. I
can't see why it's a problem to create a wxPySimpleApp() only as
a last resort, and only for interactive use. But I don't use
the pylab interface much, so maybe I'm missing something.

Sorry for the confusion. If you're not using the pylab
interface, just comment out these lines from backend_wx.py.

--Matt

···

On Sat, 9 Apr 2005 andrea_gavana@...517... wrote:

Hello NGs,

   I probably found where the problem resides. As it is a wxPython+Matplotlib
issue, I will send the mail to both newsgroups.
The reason why my application does not terminates correctly on Windows 2000
while it terminates correctly on Windows XP does not depend on Windows version,
but on Matplotlib. I am not 100% sure, because here I only have (at the
moment) Windows XP, but I found a difference between 2 Matplotlib installations
I have.
On XP, I have Matplotlib 0.73 prerelease (that WAS a prerelease 1 months
ago, nearly), while on Windows 2000 I have Matplotlib 0.74.
Well, I am using the WXAgg backend. By looking at backend_wx.py in 0.73pre
(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

While on Matplotlib 0.74 (2000) they are NOT commented. Well, in my app
I don't need to initialize the wx.App() when calling plot/figure/Matplotlib
things, because my app has ALREADY initialized the wx.App().
If I use Matplotlib (without wxPython) I will just add:

import wx
MyApp = wx.PySimpleApp()

Before using any Matplotlib command.
Is there a reason why these lines were commented on 0.73pre and now they
are not? Robin/John, could it be that the reason for which my application
does not return under Windows 2000?

Thanks to you all.

Andrea.

>andrea_gavana@...517... wrote:
>> Hello NG,
>>
>> It's incredible... after having found that my application correctly
>> terminates if I add the line:
>>
>> self.MyTaskBarIcon.Destroy()
>>
>> on Windows XP, I am UNABLE to terminate it on Windows 2000. The main
frame
>> is correctly destroyed, together with its children, but there is still
>something
>> alive that prevents Python to correctly finish and returning to me the
>control
>> of the DOS console.
>> The wxPython version is the same, the Python version is the same... the
>> only differences between the 2 PC is the Windows version (XP=work, 2000=don't
>> work) and the PC performances (XP=1GB RAM, 2000=528MB RAM).
>> I used Spy++ and its friends and, after my app terminates, on 2000 there
>> is still a window opened. This window has no class information, no particular
>> ID, only a size and position elements. There is no reason why the application
>> behavior should be different.
>> I don't even know which question I would formulate to you NG, it is a
pain
>> this continuous error-checking for a window/frame/panel that I didn't
create
>> and that wxPython thinks is still alive (only on Windows 2000).
>
>If you can create a small sample that shows the problem I can run it
>under the debugger to see if I can spot what's going on.
>
>--
>Robin Dunn
>Software Craftsman
>http://wxPython.org Java give you jitters? Relax with wxPython!

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op�k
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

The wxApp should NOT be created here! However, if there seems to be a reason that it has to be, perhaps these lines could be surrounded by a check to see if there is already a wxApp running.

Robin, is there a call to do that? Maybe:

if not wxGetApp():
     wxapp = wxPySimpleApp()
     wxapp.SetExitOnFrameDelete(True)

I just tested this quickly, and wxGetApp() returns None before app creation, and a wxApp instance after, which returns True, so it should work.

For that matter, maybe wx.PySimpleApp() should check itself, and never create a duplicate app.

By the way, it really should be:

import wx

wx.PySimpleApp()

etc.

Maybe I'll get around to cleaning up that code some day!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                          
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Hi Chris,

Attached are three patches to convert things to the new wx namespace. I am very new to matplotlib, so it might be a good idea if someone with more matplotlib and wxPython experience checks these out.

See you
Werner

Chris Barker wrote:

wxcursor_demo.patch (3.68 KB)

backend_wx.patch (55.5 KB)

backend_wxagg.patch (2.22 KB)

···

(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

The wxApp should NOT be created here! However, if there seems to be a reason that it has to be, perhaps these lines could be surrounded by a check to see if there is already a wxApp running.

Robin, is there a call to do that? Maybe:

if not wxGetApp():
    wxapp = wxPySimpleApp()
    wxapp.SetExitOnFrameDelete(True)

I just tested this quickly, and wxGetApp() returns None before app creation, and a wxApp instance after, which returns True, so it should work.

For that matter, maybe wx.PySimpleApp() should check itself, and never create a duplicate app.

By the way, it really should be:

import wx

wx.PySimpleApp()

etc.

Maybe I'll get around to cleaning up that code some day!

-Chris

Hi Chris,

A small correction to the patch for backend_wx.py.

if wxPlatform == '__WXMSW__':

on line 638 or there abouts needs to be changed

See you
Werner

Werner F. Bruhin wrote:

···

Hi Chris,

Attached are three patches to convert things to the new wx namespace. I am very new to matplotlib, so it might be a good idea if someone with more matplotlib and wxPython experience checks these out.

See you
Werner

Chris Barker wrote:

(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

The wxApp should NOT be created here! However, if there seems to be a reason that it has to be, perhaps these lines could be surrounded by a check to see if there is already a wxApp running.

Robin, is there a call to do that? Maybe:

if not wxGetApp():
    wxapp = wxPySimpleApp()
    wxapp.SetExitOnFrameDelete(True)

I just tested this quickly, and wxGetApp() returns None before app creation, and a wxApp instance after, which returns True, so it should work.

For that matter, maybe wx.PySimpleApp() should check itself, and never create a duplicate app.

By the way, it really should be:

import wx

wx.PySimpleApp()

etc.

Maybe I'll get around to cleaning up that code some day!

-Chris

Hello NGs,

On XP, I have Matplotlib 0.73 prerelease (that WAS a prerelease 1 months
ago, nearly), while on Windows 2000 I have Matplotlib 0.74.
Well, I am using the WXAgg backend. By looking at backend_wx.py in 0.73pre
(XP), I see that lines 116-117 are commented. These lines are:

# wxapp = wxPySimpleApp()
# wxapp.SetExitOnFrameDelete(True)

Yes. Having two app objects can certainly cause problems, although I
wouldn't have expected it to manifest this way. Probably what is
happening is that when the spashscreen is closed it is being added to
the pending delete list but then the new app is being created and the
pending delete list is reinitialized and so the splash screen never gets

destroyed for real so the app's MainLoop keeps running waiting for it to

be destroyed.

To find out for sure you could try uncommenting those lines on your XP

box and see if you then have the same problem.

Ok Robin, I've done what you suggested: on my XP box I uncommented the 2
lines, and the application does NOT returns. So I found where the problem
resides. It is not a wxPython nor a Windows issue, but a Matplotlib one.

Now I will probably leave them commented or I will add the Chris patch (checking
if a wx.App is already started or not).
Finding this inconsistency in Matplotlib was a 2 weeks nightmare.
Thanks for all your suggestions, NGs.

Andrea.

···

andrea_gavana@...517... wrote: