FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Keyboard shortcuts to close the figure are not active on OS X with the backend MacOSX · Issue #4372 · matplotlib/matplotlib · GitHub

Repository navigation

Keyboard shortcuts to close the figure are not active on OS X with the backend MacOSX #4372

Closed

Description

Issue

I have a special key (q) mapped to close the current figure. Using matplotlib 1.4.3 I can not close the current figure with this keymap and under the backend MacOSX. Specifically when I press the q key the keypress is sent to the shell instead.

I am currently on OSX Yosemite. My quick fix was to choose a different backed, Qt4Agg.

In my matplotlibrc file I have keymap.quit : q

Related issues

I am currently unsure if this has been fixed in the bleeding edge version of mpl. I have tested mpl-1.4.3 under a virtualenv and get the same results.

Activity

  1. tacaswell commented on Apr 23, 2015

    Member
  2. added this to the milestone on Apr 23, 2015
  3. WeatherGod commented on Apr 23, 2015

    Member

    Do you have other keys mapped to actions? Do they work? I wonder if this is
    really a terminal/figure window focus issue.

    On Thu, Apr 23, 2015 at 10:51 AM, Thomas A Caswell <notifications@github.com

    wrote:

    attn @mdehoon https://github.com/mdehoon

    —
    Reply to this email directly or view it on GitHub
    #4372 (comment)
    .

  4. mdehoon commented on Apr 24, 2015

    Contributor

    If I put keymap.quit : q in matplotlibrc and do the following:

    $ python
    Python 2.7.8 (default, Feb 27 2015, 23:52:58) 
    [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import matplotlib
    >>> matplotlib.use("macosx")
    >>> from pylab import *
    >>> figure()
    <matplotlib.figure.Figure object at 0x1043e67d0>
    >>> 
    

    then the figure closes if I click on the figure (to make it active) and press 'q'.
    If I don't click on the figure first (so the terminal keeps key input), then pressing 'q' the key press is sent to the terminal instead. Do you get the same? As far as I know, this is the desired behavior.

  5. stsievert commented on Apr 24, 2015

    Author

    I think this is a terminal/plot focus issue. When I click on the plot, both my terminal and the figure are active (screenshot).

    I have tried other keymaps. They do not work with the MacOSX backend but do work with the Qt4Agg backend.

    Is this problem unique to my system? I see this behavior even under a virtualenv after activating and running pip install matplotlib.

  6. mdehoon commented on May 1, 2015

    Contributor

    The screenshot suggests that your Python is not installed as a framework.
    See the section "Building and using a framework-based Python on Mac OS X" in the README in the subdirectory "Mac" of the Python source distribution for a full explanation.
    Did you install Python yourself, or are you using a pre-compiled version of Python?

  7. stsievert commented on May 19, 2015

    Author

    This issue can be close if it's local to my machine. I have solved it by switching backends.

    (I'm using Anaconda)

  8. mdehoon commented on May 19, 2015

    Contributor

    Let's not close this issue yet. I'd like to find out why matplotlib didn't notice that Python was not installed as a framework.

  9. mdehoon commented on May 20, 2015

    Contributor

    @scottsievert Can you have a look in your pyconfig.h to see if WITH_NEXT_FRAMEWORK is defined? It should contain the following line:
    #define WITH_NEXT_FRAMEWORK 1
    To find pyconfig.h on your computer, you can use

    >>> import sys
    >>> sys.prefix
    '/Library/Frameworks/Python.framework/Versions/2.7'

    then pyconfig.h will be in the directory sys.prefix + /include/python2.7.
    Also, can you let me know what sys.prefix returns in your case?

  10. stsievert commented on May 20, 2015

    Author
    In [1]: import sys
    
    In [2]: sys.prefix
    Out[2]: '/Users/scott/anaconda'

    The relevant part of pyconfig.h:

    /* Define if you want to produce an OpenStep/Rhapsody framework (shared
       library plus accessory files). */
    /* #undef WITH_NEXT_FRAMEWORK */

    I just installed a fresh version of Anaconda. It worked after that fresh install.

  11. mdehoon commented on May 20, 2015

    Contributor

    OK thanks. Indeed your Python is not installed as a framework. Matplotlib should have noticed that when it was compiled. Did you compile matplotlib yourself, or did you use a precompiled matplotlib?

  12. stsievert commented on May 20, 2015

    Author

    I used the version of mpl that came with Anaconda. I installed Anaconda long before this bug appeared, and the only real changes I can think of was that I upgraded anaconda (using conda upgrade anaconda) and developed a package which required I play with pandoc/markdown.

  13. stsievert commented on May 20, 2015

    Author

    Aha, got it! This is perhaps a different issue -- it is present under a freshly installed version of anaconda.

    I switched Python shells from IPython to ptipython. My keybinding 'q' works only when I use IPython. To show that, I have run the script under different python interpreters (and get different behaviors!):

    from __future__ import division
    from numpy import sin, linspace, pi
    from matplotlib.pyplot import figure, plot, show
    
    t = linspace(0, 2*pi)
    y = sin(t)
    
    figure()
    plot(t, y)
    show()

    To be clear, while I was running this, by backend was MacOSX on OSX 10.10 under a freshly installed Anaconda. Under python, ptpython and ptipython, the keymap q is sent to the shell and not to the current figure window.

  14. mdehoon commented on May 24, 2015

    Contributor

    @scottsievert I have added a run-time check to the MacOSX backend to make sure Python is installed as a framework (see the pull request). On Python2, the same check is also available as part of the MacOS module, which is part of the Python standard library. Could you try the following with python/ipython/ptpython/ptipython:

    >>> import MacOS
    >>> MacOS.WMAvailable()

    This should return True if python is installed as a framework, and False otherwise.

  15. stsievert commented on May 24, 2015

    Author
    Shell WMAvailable()
    python False
    ipython True
    ptpython False
    ptipython False
  16. mdehoon commented on Jun 1, 2015

    Contributor

    Thanks! This was fixed by pull request #4452 . The new code effectively does the same as WMAvailable().
    This issue can be closed.

  17. tacaswell commented on Jun 2, 2015

    Member

    Closed by #4452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL