| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Struggled with the Gtk3 a bit & now find the right way of doing it, so simple. 😳 |
Sorry, something went wrong.
|
Also tested on Windows7, working as expected. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks! Looks good apart from the what's new message 👍.
Could you sqash your commits if possible? - Otherwise we'll do it before merging.
Sorry, something went wrong.
| A new rcParms entry have been added: with the ``figure.raise_window`` option | ||
| now it is possible to disable the default "raise GUI window" behavior when | ||
| calling ``plt.show`` or ``plt.pause`` methods. |
There was a problem hiding this comment.
The new config option rcParams['figure.raise_window'] allows to disable
raising the plot window when calling plt.show or plt.pause methods.
Should be sufficient and more straight forward.
Sorry, something went wrong.
… (Qt,Gtk,Tk,Wx) A new rcParms entry have been added: "figure.raise_window" Now it is possible to disable the default "raise GUI window" behavior This change apply to & tested on Qt, Gtk, Tk and Wx backends (CentOS7 & Win7) Has document it in the 'whats new' section
|
Great thanks for the help on the message, i'm not a native speaker. 😂 |
Sorry, something went wrong.
There was a problem hiding this comment.
Rebase is correct 👍
What do you mean by: Qt4 "raise window" pop-out "Figure is ready", have to click the notification manually.
Sorry, something went wrong.
| # show the figure window | ||
| self.window.show() | ||
| self.window.present() | ||
| self.canvas.draw() |
There was a problem hiding this comment.
Why does GTK3 need a draw now?
Sorry, something went wrong.
There was a problem hiding this comment.
When I am testing with Gtk3 and turn off the "raise window", I encountered a strange behavior, that the GUI window is reluctant to update, and the whole program get stuck, loop is not running, until I move/switch the GUI window or moving my mouse cursor on the canvas, it can continue to run/update.
After debug and tracing, I found the program is stuck inside the Gtk.main_iteration() here:
def flush_events(self):
# docstring inherited
Gdk.threads_enter()
while Gtk.events_pending():
Gtk.main_iteration()
Gdk.flush()
Gdk.threads_leave()By looking into the doc, it says if there is no event queued, main_iteration will block until the next event is noticed, but that's very strange since we have already checked with events_pending, if there is no event it should not go into the while-loop. Nevertheless, I changed using Gtk.gtk_main_iteration_do(False) which the doc states that it won't block, however, that's not working, the program still get stuck inside gtk_main_iteration_do. Finally, I come up with a solution: to call window.queue_draw() right after window.show() and successfully I don't have to waving my mouse cursor over the canvas any more. And I found that this is exactly what canvas.draw() is doing, and the same approach is also used in the backend_wx.py, so I suppose this is the right way to do it? I am not familiar with the GUI stuff so I have no idea what's happening, please feel free to correct me.
This is the full report, HaHa!! Thank you so much for your patience reading this mumbo jumbo!! 😜
Sorry, something went wrong.
There was a problem hiding this comment.
Could you test with draw_idle instead?
Sorry, something went wrong.
There was a problem hiding this comment.
tested, won't update, need stick to draw
Sorry, something went wrong.
|
This is what I saw when I'm testing on my machine using pyqt=4 (cannot actually "raise" to top automatically, instead, have to click on the notification to bring up the window) |
Sorry, something went wrong.
|
So instead of the window, a "Figure 1 is ready" message is popping to the front? |
Sorry, something went wrong.
|
Yes! and it is exactly the one shown in the top-right corner of my attached image. |
Sorry, something went wrong.
|
Hm, I don't find any related "... is ready" text in our code base. So who is generating that message? You are seeing this only in Qt4, not Qt5, and you are on master? |
Sorry, something went wrong.
|
The message is triggered by your window manager, which isn't allowing focus stealing. |
Sorry, something went wrong.
|
Given that Qt4 is end of life and major distributions are defaulting to Qt5, I wouldn‘t wollt too much if we can‘t get this fixed for Qt4. |
Sorry, something went wrong.
|
Sure, so is there anything else I need to do? |
Sorry, something went wrong.
|
I don‘t think so. I still want to take a closer look at the GTK redraw. |
Sorry, something went wrong.
|
OK, thanks! |
Sorry, something went wrong.
|
In general this looks nice. |
Sorry, something went wrong.
|
This looks very helpful (based on a quick scan). One thought occurs to me: would it make sense to have this controlled by an optional keyword argument to plt.show? That way it could be controlled locally instead of only globally. It would require adding the keyword argument to the intermediate Figure.show and each Backend.show as well. I think the setting of the default by rcParam could stay in the backends. |
Sorry, something went wrong.
|
Thanks for the advice, seems reasonable to me. But they could be discussed & handled in separated issue & PR, IMHO. |
Sorry, something went wrong.
|
Any update on this? |
Sorry, something went wrong.
There was a problem hiding this comment.
I think we should get this in ASAP. I don't see how it can do any real harm, and it is an important feature requiring minimal code.
Sorry, something went wrong.
|
I think the whatsnew should at least mention that this doesn't work on the macos backend (which is fine); clarifying (as above) the interaction with the tk.window_focus rc would be nice as well. |
Sorry, something went wrong.
|
@anntzer Good points. If this goes in, will you want to support the rcParam in your mplcairo backend? |
Sorry, something went wrong.
|
I haven't actually checked, but I'm almost certain mplcairo will work just fine with it because it just inherits the show() methods from the various backend-dependent but renderer-independent base classes (similarly, you can see that here the changes are in qt5.py wx.py etc. and not qt5agg.py/qt5cairo.py wxagg.py/wxcairo.py etc.). |
Sorry, something went wrong.
|
I think this functionality is not exactly identical to the rcParams["tk.window_focus"]. |
Sorry, something went wrong.
|
Add this to whatsnew?
|
Sorry, something went wrong.
There was a problem hiding this comment.
conditional on adding a note about OSX not being supported (or explicitly listing the backends that are supported).
Sorry, something went wrong.
|
done~ |
Sorry, something went wrong.
|
Is there a fix for OSX? |
Sorry, something went wrong.
|
Hello, changing rcParams figure.raise_window keyword to False gives inconsistent behavior. Here's a simple example: import matplotlib
from matplotlib import pyplot as plt
matplotlib.use('qt5agg')
if matplotlib.rcParams['figure.raise_window']:
matplotlib.rcParams['figure.raise_window'] = False
plt.plot([1,2,3],[3,4,5],'.')
plt.show()
When I run the example code in Spyder, the initial run works as intended: the new plot window does not "rise above" the console window. However, subsequent runs of the same code do not behave the same way: the new plot window still rises above the console window, even when the keyword is set to False. Moreover, running the code in the command prompt also does not produce the desired effect: the new plot window always rises above the command prompt window. I am using Windows 10, Python 3.7.6, Matplotlib 3.4.2, and Spyder 5.0.0 I am commenting here in hopes that the original developer(s) of this feature can see this. Thanks. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Address Issue #8692
A new rcParms entry have been added: "figure.raise_window"
Now it is possible to disable the default "raise GUI window" behavior
This change apply to & tested on Qt4, Qt5, Gtk3, Tk and Wx backends (OS: CentOS7, Win7)
Has document it in the 'whats new' section
Known Issue:
Gtk3 have to use a small trick to force the screen update, better solutions welcome
Qt4 "raise window" pop-out "Figure is ready", have to click the notification manually
Side Note:
Wx backend didn't implement the "raise window" behavior before
Don't have a Mac to work on macosx backend
Manually tested with the attached python script
test_raise_window.txt
PR Checklist