Autonomous display of image/plot/figure

I would think that the gtk mainloop would terminate when the window
closes (which termination should propagate back up the stack), but
apparently that doesn't happen.

I'm not sure I'm following you at the moment. Are you calling show()
once and closing the figure doesn't cause it to return? or are you
trying to call show() multiple times from a single script and subsequent
calls to show() fail to return?

Hi, Ryan,

Thanks for your continued help.

I am calling show() once, and closing the figure doesn't cause it to return? I've verified the lack of return using debug sys.stderr.write() statements, as well as by following show() with a sys.exit() command.

(Getting this back on the full list...)

This sounds like a bug to me, specific to your set up. I just ran a script (for my own sanity) and closing the figure, resulted in the script exiting and returning to the command prompt. Do you happen to have a small complete example that replicates your problems that you could post here?

Also, what are your versions of matplotlib and PyGtk (you are using GtkAgg, right)? Also, what OS are you running?

Devs, what do you think?

Ryan

···

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Thanks, Ryan, The requested info is below.
Thanks again.
    James

- ----- SMALL COMPLETE EXAMPLE CODE FOLLOWS -------------
#!/usr/bin/python
# File: test.py

import os,sys
import pylab as PL
import numpy as N

def main():
  fig = PL.figure(1)
  x = N.arange(120.0)*2*N.pi/120.0
  x = PL.resize(x, (100,120))
  y = N.arange(100.0)*2*N.pi/100.0
  y = N.resize(y, (120,100))
  y = N.transpose(y)
  z = N.sin(x) + N.cos(y)
  PL.imshow( z , cmap=PL.cm.jet)#, interpolation='nearest')
  sys.stderr.write("Begun.")
  PL.show()
  sys.stderr.write("Done.")
  sys.exit(0)

if __name__ == "__main__":
- ---- END OF SAMPLE CODE -------------------

Sample output:
- ------- BEGIN --------------
\./test\.py Begun\. \- \-\-\-\-\-\-\- COMMENTS: \-\-\-\-\-\-\-\-\-\-\-\-\-\-               The image displays\.                I click on the X; the image disappears\.               Nothing happens in the terminal output\.               In the terminal window I type <ctrl>C\. \- \-\-\-\-\-\-\- BEGIN \-\-\-\-\-\-\-\-\-\-\-\-\-\- ^CTraceback \(most recent call last\):   File "\./test\.py", line 59, in <module>     main\(\)   File "\./test\.py", line 25, in main     PL\.show\(\)   File "/usr/lib/python2\.5/site\-packages/matplotlib/backends/backend\_gtk\.py", line 71, in show     gtk\.main\(\) KeyboardInterrupt
- ------ END OF OUTPUT CODE ----------

The same behavior occurs when run from within an interactive session.

python version: 2.5.1 (4251:54863, Jun 15 2008, 23:59:20)
Matplotlib version: 0.91.2
PyGTK version: 2.12.0-2.fc8
In ~/.matplotlib/matplotlibrc: backend : GTKAgg
OS: Fedora 8
Linux kernel: 2.6.25.6-27.fc8

···

On Monday 14 July 2008 21:22:31 you wrote:

>>> I would think that the gtk mainloop would terminate when the window
>>> closes (which termination should propagate back up the stack), but
>>> apparently that doesn't happen.
>>
>> I'm not sure I'm following you at the moment. Are you calling show()
>> once and closing the figure doesn't cause it to return? or are you
>> trying to call show() multiple times from a single script and subsequent
>> calls to show() fail to return?
>
> Hi, Ryan,
>
> Thanks for your continued help.
>
> I am calling show() once, and closing the figure doesn't cause it to
> return? I've verified the lack of return using debug sys.stderr.write()
> statements, as well as by following show() with a sys.exit() command.

(Getting this back on the full list...)

This sounds like a bug to me, specific to your set up. I just ran a
script (for my own sanity) and closing the figure, resulted in the
script exiting and returning to the command prompt. Do you happen to
have a small complete example that replicates your problems that you
could post here?

Also, what are your versions of matplotlib and PyGtk (you are using
GtkAgg, right)? Also, what OS are you running?

Devs, what do you think?

Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

I am not seeing any problems on the 91 branch or the 98 trunk. Below
is my command and output (the shell returns when I close the window
with a click)

johnh@...1653...:svn> python ~/test.py --verbose-helpful -dGTKAgg
$HOME=/home/titan/johnh
CONFIGDIR=/home/titan/johnh/.matplotlib
matplotlib data path
/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/mpl-data
loaded rc file /home/titan/johnh/.matplotlib/matplotlibrc
matplotlib version 0.91.4
verbose.level helpful
interactive is False
units is False
platform is sunos5
numerix numpy 1.2.0.dev5410
Using fontManager instance from /home/titan/johnh/.matplotlib/fontManager.cache
backend GTKAgg version 2.6.0
Begun.Done.johnh@...1653...:svn>

···

On Tue, Jul 15, 2008 at 8:39 AM, James K. Gruetzner <jkgruet@...176...> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 14 July 2008 21:22:31 you wrote:

>>> I would think that the gtk mainloop would terminate when the window
>>> closes (which termination should propagate back up the stack), but
>>> apparently that doesn't happen.
>>
>> I'm not sure I'm following you at the moment. Are you calling show()
>> once and closing the figure doesn't cause it to return? or are you
>> trying to call show() multiple times from a single script and subsequent
>> calls to show() fail to return?
>
> Hi, Ryan,
>
> Thanks for your continued help.
>
> I am calling show() once, and closing the figure doesn't cause it to
> return? I've verified the lack of return using debug sys.stderr.write()
> statements, as well as by following show() with a sys.exit() command.

(Getting this back on the full list...)

This sounds like a bug to me, specific to your set up. I just ran a
script (for my own sanity) and closing the figure, resulted in the
script exiting and returning to the command prompt. Do you happen to
have a small complete example that replicates your problems that you
could post here?

Also, what are your versions of matplotlib and PyGtk (you are using
GtkAgg, right)? Also, what OS are you running?

Devs, what do you think?

Ryan
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Thanks, Ryan, The requested info is below.
Thanks again.

Hi, John,

Here's my equivalent:

$ python ./test.py --verbose-helpful -dGTKAgg
$HOME=/home/jkgruet
CONFIGDIR=/home/jkgruet/.matplotlib
matplotlib data path /usr/lib/python2.5/site-packages/matplotlib/mpl-data
loaded rc file /home/jkgruet/.matplotlib/matplotlibrc
matplotlib version 0.91.2
verbose.level helpful
interactive is True
units is False
platform is linux2
numerix numpy 1.1.0
Using fontManager instance from /home/jkgruet/.matplotlib/fontManager.cache
backend GTKAgg version 2.12.0
Begun.

  . . . at which point it hangs, even after the window is closed.

I see that I have a older matplotlib and numpy versions. Those are the same
versions as in Fedora 9, so upgrading there won't help.

OTOH, my GTKAgg version is 2.12,0, not 2.6.0. I'm fairly sure that is where
the problem lies, or, more likely, in GTK itself, where I have installed:

gtk+.i386 1:1.2.10-59.fc8
gtk2.i386 2.12.8-2.fc8

This is verified by testing several backends:
  GTKAgg: fails to return when X is clicked
  GTK: fails to return when X is clicked
  GTKCairo: fails to return when X is clicked
  WxAgg: displays and returns immediately (no need to click any X !!! )
  QtAgg: returns when X is clicked;
  TkAgg: returns when X is clicked;
  FltkAgg: "ImportError: No module named fltk", although fltk is installed
  WX: "NotImplementedError" from .../matplotlib/image.py in draw:
renderer.draw_Image(...)
  
So . . . for my purposes, I think I'll just use QtAgg or TkAgg.

I'm not sure how I would file a bug report against GTK, however, or even *if*
I should file one given my utter ignorance of gtk.

I appreciate all the help shown on the list. Y'all're very kind.

   James

···

On Tuesday 15 July 2008 07:48:45 John Hunter wrote:

On Tue, Jul 15, 2008 at 8:39 AM, James K. Gruetzner <jkgruet@...176...> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Monday 14 July 2008 21:22:31 you wrote:
>> >>> I would think that the gtk mainloop would terminate when the window
>> >>> closes (which termination should propagate back up the stack), but
>> >>> apparently that doesn't happen.
>> >>
>> >> I'm not sure I'm following you at the moment. Are you calling show()
>> >> once and closing the figure doesn't cause it to return? or are you
>> >> trying to call show() multiple times from a single script and
>> >> subsequent calls to show() fail to return?
>> >
>> > Hi, Ryan,
>> >
>> > Thanks for your continued help.
>> >
>> > I am calling show() once, and closing the figure doesn't cause it to
>> > return? I've verified the lack of return using debug
>> > sys.stderr.write() statements, as well as by following show() with a
>> > sys.exit() command.
>>
>> (Getting this back on the full list...)
>>
>> This sounds like a bug to me, specific to your set up. I just ran a
>> script (for my own sanity) and closing the figure, resulted in the
>> script exiting and returning to the command prompt. Do you happen to
>> have a small complete example that replicates your problems that you
>> could post here?
>>
>> Also, what are your versions of matplotlib and PyGtk (you are using
>> GtkAgg, right)? Also, what OS are you running?
>>
>> Devs, what do you think?
>>
>> Ryan
>> --
>> Ryan May
>> Graduate Research Assistant
>> School of Meteorology
>> University of Oklahoma
>
> Thanks, Ryan, The requested info is below.
> Thanks again.

I am not seeing any problems on the 91 branch or the 98 trunk. Below
is my command and output (the shell returns when I close the window
with a click)

johnh@...1653...:svn> python ~/test.py --verbose-helpful -dGTKAgg
$HOME=/home/titan/johnh
CONFIGDIR=/home/titan/johnh/.matplotlib
matplotlib data path
/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/mpl-data
loaded rc file /home/titan/johnh/.matplotlib/matplotlibrc
matplotlib version 0.91.4
verbose.level helpful
interactive is False
units is False
platform is sunos5
numerix numpy 1.2.0.dev5410
Using fontManager instance from
/home/titan/johnh/.matplotlib/fontManager.cache backend GTKAgg version
2.6.0
Begun.Done.johnh@...1653...:svn>

I just tested on gtk 2.12.0 and did not see the problem with mpl 0.98
and backend gtkagg. Not sure why you are having these problems...

JDH

···

On Tue, Jul 15, 2008 at 10:48 AM, James K. Gruetzner <jkgruet@...176...> wrote:

OTOH, my GTKAgg version is 2.12,0, not 2.6.0. I'm fairly sure that is where
the problem lies, or, more likely, in GTK itself, where I have installed: