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 9135799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:52:13+00:00 2026-06-17T08:52:13+00:00

Is there some way that I can get matplotlib to block code execution pending

  • 0

Is there some way that I can get matplotlib to block code execution pending a matplotlib.backend_bases.Event?

I’ve been working on some classes for interactively drawing lines and polygons inside matplotlib figures, following these examples. What I’d really like to do is block execution until I’m done editing my polygon, then get the final positions of the vertices – if you’re familiar with MATLAB, I’m basically trying to replicate the position = wait(roihandle) syntax, for example here.

I suppose I could set some class attribute of my interactive polygon object when a keypress occurs, then repeatedly poll the object in my script to see if the event has occurred yet, but I was hoping there would be a nicer way.

  • 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-17T08:52:13+00:00Added an answer on June 17, 2026 at 8:52 am

    Well, that was easier than I thought it would be! For those who are interested I found a solution using figure.canvas.start_event_loop() and figure.canvas.stop_event_loop().

    Here’s a simple example:

    from matplotlib import pyplot as plt
    
    class FigEventLoopDemo(object):
    
        def __init__(self):
    
            self.fig, self.ax = plt.subplots(1, 1, num='Event loop demo')
            self.clickme = self.ax.text(0.5, 0.5, 'click me',
                                        ha='center', va='center',
                                        color='r', fontsize=20, picker=10)
    
            # add a callback that triggers when the text is clicked
            self.cid = self.fig.canvas.mpl_connect('pick_event', self.on_pick)
    
            # start a blocking event loop
            print("entering a blocking loop")
            self.fig.canvas.start_event_loop(timeout=-1)
    
        def on_pick(self, event):
    
            if event.artist is self.clickme:
    
                # exit the blocking event loop
                self.fig.canvas.stop_event_loop()
                print("now we're unblocked")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way I can fix this so that I can get the
Is there any way to get the text of the selector that invoked some
Is there some way when sending this message to specify that I rather have
I've always wondered is there a better way that I should be writing some
Is there a way to create a JAR-file that contains some arguments that are
I'm testing some cookies that I'm creating via JavaScript. Is there a way to
I'm developing a program that makes some floating points calculations. Is there any way
I've been given some code that compiles fine on MSVC, and I'm trying to
We would like to know if there is some way to get the current
In Xcode 4 is there a way I can set tags on my code

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.