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

  • Home
  • SEARCH
  • 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 9041425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:14:10+00:00 2026-06-16T10:14:10+00:00

I’m working on a Python app that uses wxPython for a GUI with an

  • 0

I’m working on a Python app that uses wxPython for a GUI with an embedded matplotlib figure. It was going really well until I tried to use a matplotlib GUI-neutral widget called a SpanSelector. Before, I was trying to code this behavior myself, which wasn’t going very well, so I was pleased that there was a built-in widget that would take care of it for me. These widgets are supposed to work with any GUI backend, and wxPython is definitely a supported backend.

My code is pretty simple at the moment; I have a defined application class with these (relevant) functions:

def init_gui(self):
    ...
    self.button5 = wx.Button(tab, label="Manual select", size=(120, 30))
    self.button5.Bind(wx.EVT_BUTTON, self.get_selection_manual)
    ...

def get_selection_manual(self, event):
    span = matplotlib.widgets.SpanSelector(self.ax, \
        self.process_selection_manual, "horizontal", useblit=True, \
        rectprops=dict(alpha=0.5, facecolor="red"))

def process_selection_manual(self, vmin, vmax):
    print vmin, vmax

If it was working, all it should do is print out the selection the user made after clicking the button. I know that get_selection_manual is called, but clicking and dragging over the plot never creates a selection, and the callback process_selection_manual is never called.

I tried putting in a sleep() and then updating the display. Interestingly, I got it to (sort of) work when my application crashed over a sleep(5) instead of a time.sleep(5). So Python was stalled, but it drew the selection like it was supposed to then. I’ve never seen that happen before, and I’m not really sure what it means. I haven’t found any examples of using wxPython and matplotlib widgets together, so any help is greatly appreciated.

  • 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-16T10:14:11+00:00Added an answer on June 16, 2026 at 10:14 am

    This turned out to be a really simple solution: span has to be declared self.span… Maybe it was getting garbage-collected before it could do anything? In any case, it works now if I replace

    def get_selection_manual(self, event):
        span = matplotlib.widgets.SpanSelector(self.ax, \
            self.process_selection_manual, "horizontal", useblit=True, \
            rectprops=dict(alpha=0.5, facecolor="red"))
    

    with

    def get_selection_manual(self, event):
        self.span = matplotlib.widgets.SpanSelector(self.ax, \
            self.process_selection_manual, "horizontal", \
            rectprops=dict(alpha=0.5, facecolor="red"))
    

    I also removed the useblit flag because it messed up the color; I don’t think it was relevant to this fix, but still useful to note.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I know there's a lot of other questions out there that deal with this

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.