Does anybody know why the show._needmain stuff is needed in the show() function 
in backend_tkagg.py? Currently, this function is as follows:

def show():
    """
    Show all the figures and enter the gtk mainloop

    This should be the last line of your script.  This function sets
    interactive mode to True, as detailed on
    http://matplotlib.sf.net/interactive.html
    """
    for manager in Gcf.get_all_fig_managers():
        manager.show()
    import matplotlib
    matplotlib.interactive(True)
    if rcParams['tk.pythoninspect']:
        os.environ['PYTHONINSPECT'] = '1'
    if show._needmain:
        Tk.mainloop()
        show._needmain = False
show._needmain = True


If I remove the show._needmain stuff, as in:

def show():
    """
    Show all the figures and enter the gtk mainloop

    This should be the last line of your script.  This function sets
    interactive mode to True, as detailed on
    http://matplotlib.sf.net/interactive.html
    """
    for manager in Gcf.get_all_fig_managers():
        manager.show()
    import matplotlib
    matplotlib.interactive(True)
    if rcParams['tk.pythoninspect']:
        os.environ['PYTHONINSPECT'] = '1'
    Tk.mainloop()

then the function still seems to work fine, and multiple show()s also works.

--Michiel.


--- On Thu, 8/20/09, Kim, Dae-Won <dwki...@gmail.com> wrote:

> From: Kim, Dae-Won <dwki...@gmail.com>
> Subject: Re: [Matplotlib-users] show() problem in Mac OS X 10.5.8
> To: "Michiel de Hoon" <mjldeh...@yahoo.com>
> Cc: "Ryan May" <rma...@gmail.com>, matplotlib-users@lists.sourceforge.net
> Date: Thursday, August 20, 2009, 10:26 AM
> 
> I tested with TKAgg and WXAgg. I just bought macbook and
> I'm newbie yet. Do I need to set something special for
> the multiple show()s?
> 
> Thanks,
> 
> -Dae-Won
> 
> On Thu, Aug 20, 2009 at 10:01 AM,
> Michiel de Hoon <mjldeh...@yahoo.com>
> wrote:
> 
> 
> Whether or not you can do multiple
> show()s depends on which backend you use. For example, the
> Mac OS X native backend has no problems with the multiple
> show()s in your example. Which backend were you using? While
> matplotlib does not support multiple show()s in general,
> there may be a simple solution to get that working for the
> backend you are using.
> 
> 
> 
> 
> 
> --Michiel.
> 
> 
> 
> --- On Wed, 8/19/09, Kim, Dae-Won <dwki...@gmail.com>
> wrote:
> 
> 
> 
> > From: Kim, Dae-Won <dwki...@gmail.com>
> 
> > Subject: Re: [Matplotlib-users] show() problem in Mac
> OS X 10.5.8
> 
> > To: "Ryan May" <rma...@gmail.com>
> 
> > Cc: matplotlib-users@lists.sourceforge.net
> 
> > Date: Wednesday, August 19, 2009, 2:48 PM
> 
> >
> 
> >  The one 'preliminary' solution I found is
> using
> 
> > an interactive mode + raw_input.
> 
> > Here is and example,
> 
> >
> 
> >         ion()
> 
> >         plot([1,2,3,4,5])
> 
> >         raw_input('Type Enter')
> 
> >         clf()
> 
> >
> 
> >
> 
> >         plot([1,2,3,4,5])
> 
> >         raw_input('Type_Enter')
> 
> >         clf()
> 
> >         plot([1,2,3,4,5])
> 
> >         show()
> 
> >
> 
> > With this approach, I can press the enter when I want
> to
> 
> > see next figure.
> 
> >
> 
> >
> 
> >
> 
> > Though It's not as convenient as 'multiple
> 
> > show()'..
> 
> >
> 
> >
> 
> > On Wed, Aug 19, 2009 at 1:57 PM,
> 
> > Kim, Dae-Won <dwki...@gmail.com>
> 
> > wrote:
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > On Wed, Aug 19, 2009 at 1:02 PM,
> 
> > Ryan May <rma...@gmail.com>
> 
> > wrote:
> 
> >
> 
> >
> 
> >
> 
> > On Wed, Aug 19, 2009 at 11:55
> 
> > AM, coati <dwki...@gmail.com>
> 
> > wrote:
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >  I have a problem with show() command in my macbook
> 
> > machine (Leopard 10.5.8).
> 
> >
> 
> > For example, if I run the script shown below
> 
> >
> 
> > (let assume it is saved as 'test.py', and I
> run a
> 
> > command 'python test.py'),
> 
> >
> 
> >
> 
> >
> 
> > ---------------------------------------
> 
> >
> 
> >
> 
> >
> 
> > plot([1,2,3,4,5])
> 
> >
> 
> > show() #first window
> 
> >
> 
> > plot([1,2,3,4,5])
> 
> >
> 
> > show() #second window
> 
> >
> 
> > plot([1,2,3,4,5])
> 
> >
> 
> > show() #third window
> 
> >
> 
> >
> 
> >
> 
> > ---------------------------------------
> 
> >
> 
> >
> 
> >
> 
> > Then the first window just pops up and I can see a
> 
> > beautiful straight line
> 
> >
> 
> > :) No problem so far.
> 
> >
> 
> > But, after I close the first window by clicking the
> close
> 
> > button of the
> 
> >
> 
> > window,
> 
> >
> 
> > other two window (second and third) just pops up and
> close
> 
> > themselves
> 
> >
> 
> > instantly
> 
> >
> 
> > even though I didn't click the close button...
> 
> >
> 
> > Also, the second and third plot is shown in the same
> 
> > window.
> 
> >
> 
> >
> 
> >
> 
> > I don't have such problem in my Ubuntu machine..
> 
> >
> 
> >
> 
> >
> 
> > Does anybody know reasons?
> 
> > show() actually handles starting the GUI mainloop, so
> you
> 
> > really shouldn't be calling it more than once from
> a
> 
> > script.  Quite frankly, it's more amazing that it
> works
> 
> > on your Ubuntu macine. :)  If you're wanting 3
> separate
> 
> > windows, try:
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > plot([1,2,3,4,5])
> 
> > figure()
> 
> > plot([1,2,3,4,5])
> 
> > figure()
> 
> > plot([1,2,3,4,5])
> 
> > show()
> 
> >
> 
> > Ryan
> 
> >
> 
> > --
> 
> > Ryan May
> 
> >
> 
> > Graduate Research Assistant
> 
> > School of Meteorology
> 
> > University of Oklahoma
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Thanks Ryan,
> 
> >
> 
> > Hm.. it's a bit strange.. I just installed
> matplotlib
> 
> > at Ubuntu using the package manager :)
> 
> > And, another linux machines (red hat enterprise) can
> do
> 
> > this too. For the RHELs, I compiled matplotlib source
> code
> 
> > by myself.
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > figure() works very well, but what I want to do is to
> check
> 
> > the plots one by one and thus
> 
> > I can exit the script at any time I want (because I
> usually
> 
> > have lots of figures to check and I don't want
> 
> > to pop up every of them at the same time..)
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > Anyway, thank you very much!
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> >
> 
> > -----Inline Attachment Follows-----
> 
> >
> 
> >
> ------------------------------------------------------------------------------
> 
> > Let Crystal Reports handle the reporting - Free
> Crystal
> 
> > Reports 2008 30-Day
> 
> > trial. Simplify your report design, integration and
> 
> > deployment - and focus on
> 
> > what you do best, core application coding. Discover
> what's
> 
> > new with
> 
> > Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> 
> > -----Inline Attachment Follows-----
> 
> >
> 
> > _______________________________________________
> 
> > Matplotlib-users mailing list
> 
> > Matplotlib-users@lists.sourceforge.net
> 
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> >
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 


      

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to