Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7983293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:55:19+00:00 2026-06-04T10:55:19+00:00

import sys import matplotlib import matplotlib.pyplot as plt print matplotlib.__version__, matplotlib.get_backend() def hit(event): sys.stderr.write(‘hit\n’)

  • 0
import sys
import matplotlib
import matplotlib.pyplot as plt
print matplotlib.__version__, matplotlib.get_backend()

def hit(event):
  sys.stderr.write('hit\n')

fig = plt.figure()
cid0 = fig.canvas.mpl_connect('key_press_event', hit)
cid1 = fig.canvas.mpl_connect('button_press_event', hit)
print cid0, cid1
plt.show()

With the code above, why can’t I have both mouse press event and key press events firing hit? It seems in the order above only the key press events work, whereas if I swap the lines 10 and 11 around (order cid0 and cid1 assignment), then only the mouse events work. I.e. whichever one I connected first hogs the event handler. Is this a built in limitation of matplotlib, or am I trying to connect multiple events in the wrong way?

edit with some extra info: My matplotlib.__version__ is 1.1.0. I have tried with GTKAgg and TkAgg backends with the same result. Using python and ipython, with or without -wthread -pylab, ipython qtconsole --pylab=inline, does not make a difference. The connection ids I get are cid0 == cid1 == 6.

edit 2: My problem still remains today with matplotlib version 1.2.x and TkAgg backend, sys.version 2.7.2+ (default, Oct 4 2011, 20:06:09) [GCC 4.6.1]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:55:20+00:00Added an answer on June 4, 2026 at 10:55 am

    I think you stumbled upon this bug: Multiple mpl_connect calls ignored

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import sys def a(): print 'aaa' def profiler(frame, event, arg): print event, frame.f_code.co_name, frame.f_lineno,
cat file_ro.py import sys def file_open(filename): fo=open(filename,'r') fo.seek(7) read_data=fo.read(3) fo.close() print read_data file_open(file.py) But
#!/usr/bin/python2.4 import logging import sys import doctest def foo(x): >>> foo (0) 0 print
import os import sys class Corrector: def correctAll(dir): print ok c = Corrector() c.correctAll(os.getcwd())
import time import sys sys.stdout.write(1) time.sleep(5) print(2) will print 12 after 5 seconds import
import sys, os X = os.system(ipconfig) print X 0 I know its simple, I'm
The python implementation import sys def move(src, dst, tmp, num): if num == 1:
import sys def keepsumming(number): numberlist = [] for digit in str(number): numberlist.append(int(digit)) total =
TL/DR: import gc, sys print len(gc.get_objects()) # 4073 objects in memory # Attempt to
$ cat script.py import sys for line in sys.stdin: sys.stdout.write(line) sys.stdout.flush() $ cat script.py

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.