-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Starting pylab or creating new figures steals focus #8246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Using the |
Flagging this a critical to make sure we talk about it. |
Edit: Nevermind, I just found the discussion around #12188 which (hopefully) will also fix #8246 in the next release. Fingers crossed.🍀
I am on OSX 10.14, |
Is there any solution or hack to address this? Although bring-to-front is nice, I really want to avoid loosing the focus from the terminal. Tested with:
In the last case, the focus is not stolen for window creation until I've created and closed some figures to begin with. |
This is still a problem for:
At least for ipython --pylab start up |
This was annoying me enough that I tracked it down. It's an IPython thing and nothing to do with matplotlib per se. The cause is that as soon as you start processing events on a QApplication the MacOS dock entry is created and the application is activated. I couldn't find a way to stop the application being immediately activated (or to easily deactivate it once it's first activated), so my fix is to not process any Qt events in the IPython event hook until a window has been created, e.g. a matplotlib figure is shown. https://gist.github.com/pag/f7d1ebbd1b14fe9058bf68d73a52bc84 It's working nicely. The only downside is that people using the IPython/Qt event loop integration for things other than plotting (via |
I think it is a little worse, if people were sloppy and relied on IPython to create the qapplication from them, the first attempt at creating a a QWidget would abort their process. That said, @pag can you open a PR to IPython with that patch (and ping me, I can help review / shepherd it through there). A slightly simpler change may be to only process events if someone else has created a QAppliaction and never have IPython create one. I have in the past had the opposite view on this, but am starting to change my mind. This is also
which will prevent new windows from stealing focus. |
@tacaswell with the patch a QApplication is still created at the moment of GUI loop integration (i.e. the moment that you run |
@pag 🐑 Sorry, I did not read the diff correctly, sorry about that. I still think you should consider opening this as a PR to IPython (if you have not done so already and the notification is just lost in my inbox). |
hey! was a PR opened for that in IPython? if so, what's the link? |
There is at least an issue on the IPython side to track this ipython/ipython#13617 |
I am going to close this because:
|
I'm using matplotlib 2.0.0 installed via anaconda with ipython 4.2.0 on mac os x 10.9.5. Since upgrading to matplotlib 2.0.0, whenever I start a matplotlib-enabled session (e.g.,
ipython --matplotlib
) or a new window is created, it steals focus from the OS. I'm using theTkAgg
backend, though the same thing happens with Qt5.This is particularly a problem for some test codes that create a large number of windows while running; I effectively cannot access the OS at all when the tests are running, even the terminal, so I can't kill the thread.
Any suggestions on what might have happened with this latest upgrade? Since this was anaconda-installed, I can't rule out a change in the backends rather than with matplotlib, but I think the relevant expertise is likelier to be here.
The text was updated successfully, but these errors were encountered: