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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:15:22+00:00 2026-05-27T10:15:22+00:00

This is my first question of stackoverflow! I’ve got a PyQT gui that’s displaying

  • 0

This is my first question of stackoverflow! I’ve got a PyQT gui that’s displaying an mpl figure canvas. I’ve set the margins around my main axes to 0 so the plot will completely fill the figure canvas and the widget that contains it. The problem is that when I do this I no longer get the axes_leave_event when I leave the figure canvas. For example when I’ve clicked on the pan button in the mpl_toolbar my cursor changes to the cross-arrows but when I leave the widget I’d like it to return to normal and return to the cross-arrows when I reenter the widget. If I don’t minimize my margins around the axes then it works like I would like. I can also connect the axes_leave_event but I don’t want to connect it I want to emit it and can’t figure out how to do that.

Thanks so much all.

My application is fairly large so I’ll just show the code that I think is most relevent.

    def create_main_frame(self):
        self.dpi = 100
        self.fig = Figure((5.0, 4.0), dpi=self.dpi)
        self.fig.subplots_adjust(left = 0, right=1, top=1, bottom=0)
        self.map_canvas = MyDiagram(self.fig)
        
        self.add_axis()
           
        self.mpl_toolbar = NavigationToolbar(self.map_canvas, None)
        self.layout().addWidget(self.map_canvas)  


class MyDiagram(FigureCanvas):
    def __init__(self, fig):
        FigureCanvas.__init__(self, fig)
        self.mpl_connect('axes_leave_event', self.testing)
    def resizeEvent(self, event):
        if not event.size().height() == 0:
            FigureCanvas.resizeEvent(self, event)

    def testing(self, event):
        pass

    def leaveEvent(self, event):
        FigureCanvas.leaveEvent(self, event)
        #If I could somehow get the 'axes_leave_event' to fire right here I would be set.
  • 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-05-27T10:15:22+00:00Added an answer on May 27, 2026 at 10:15 am

    This is somewhat based on guesswork, since I can’t test it with matplotlib, but something along these lines might work:

    class MyDiagram(FigureCanvas):
        def __init__(self, fig):
            FigureCanvas.__init__(self, fig)
            self._cursor = None
    
        def enterEvent(self, event):
            if (self._cursor is not None and
                QApplication.overrideCursor() is None):
                QApplication.setOverrideCursor(self._cursor)
            FigureCanvas.enterEvent(self, event)
    
        def leaveEvent(self, event):
            self._cursor = QCursor(QApplication.overrideCursor())
            QApplication.restoreOverrideCursor()
            FigureCanvas.leaveEvent(self, event)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first question here on stackoverflow, so I hope that I am
This is my first question on stackoverflow (I have usually been able to figure
this is my first question on StackOverflow, but I think that we'll both come
this is my first question to stackoverflow so here it goes... I use cruise
This is my first question on stackoverflow. I just wonder why my getJSON code
This is my first StackOverflow question so be nice! :-) I recently came across
Greetings to all! This is my first question here on stackoverflow. I have a
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
This is my first question at stackoverflow :-). However, I've started to Android programming
This is the first time I am posting a question on stackoverflow, so please

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.