-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MEP27 Decouple pyplot from backends (refactoring Gcf out of backend code) #4143
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
Changes from 1 commit
24caf2b
2b05d38
f4fc354
0b31e3a
6fb452e
0a868a2
61ba2b4
f0eb84c
8fe9cd7
494e5f1
ed16178
21b8f58
cf42e3b
f027b16
24b7b73
bc99129
7f7f05e
713abcb
80adaaf
4e5f69d
160ef57
b6d6acc
ecd5038
f8e83fe
c53b79a
34c6b12
8a4268a
44df199
860a8ed
c44e744
2fe9215
3b434ef
490629f
8eb987b
224a4f3
cdbd51b
50e3719
85be519
7edaf5a
8e6e252
72575cb
4a78246
e300707
ee76451
6f0c7ab
ae9bf5b
fb004e0
1d2095b
24e43b3
208c3be
a44ebd9
f8f9cf2
0e09a54
a38b6d7
64f0c61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,18 +76,21 @@ def show_all(cls, block=None): | |
for manager in managers: | ||
manager.show() | ||
|
||
if block is not None: | ||
if block: | ||
manager._mainloop() | ||
if block is True: | ||
manager._mainloop() | ||
return | ||
elif block is False: | ||
return | ||
|
||
# Hack: determine at runtime whether we are | ||
# inside ipython in pylab mode. | ||
from matplotlib import pyplot | ||
try: | ||
ipython_pylab = not p 8000 yplot.show._needmain | ||
# IPython versions >= 0.10 tack the _needmain | ||
# attribute onto pyplot.show, and always set | ||
# it to False, when in %pylab mode. | ||
ipython_pylab = ipython_pylab and get_backend() != 'WebAgg' | ||
ipython_pylab = ipython_pylab and manager.backend_name != 'webagg' | ||
# TODO: The above is a hack to get the WebAgg backend | ||
# working with ipython's `%pylab` mode until proper | ||
# integration is implemented. | ||
|
@@ -97,9 +100,9 @@ def show_all(cls, block=None): | |
# Leave the following as a separate step in case we | ||
# want to control this behavior with an rcParam. | ||
if ipython_pylab: | ||
block = False | ||
return | ||
|
||
if not is_interactive() or get_backend() == 'WebAgg': | ||
if not is_interactive() or manager.backend_name == 'webagg': | ||
manager._mainloop() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh? if it isn't interactive, then start a mainloop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of this method I just copy pasted from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably be good to explain that in a comment |
||
|
||
@classmethod | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
from matplotlib import is_interactive | ||
|
||
from matplotlib.figure import Figure | ||
from matplotlib.backends import get_backend | ||
from matplotlib.backends import get_backend, backend as backend_name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this one of the sources of the global state that needs to be pushed back into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
class FigureManagerEvent(object): | ||
|
@@ -75,7 +75,7 @@ class FigureManager(cbook.EventEmitter): | |
""" | ||
def __init__(self, figure, num, **kwargs): | ||
super(FigureManager, self).__init__(**kwargs) | ||
self._backend = get_backend() | ||
self._backend_name, self._backend = get_backend() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you ask the |
||
|
||
self.num = num | ||
self.figure = figure | ||
|
@@ -193,6 +193,10 @@ def set_window_title(self, title): | |
def backend(self): | ||
return self._backend | ||
|
||
@property | ||
def backend_name(self): | ||
return self._backend_name | ||
|
||
def _get_toolbar(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not put it as a property? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because you did it like this in MEP22, so I just copy and paste it over :P. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ups... I think it would look better as a property don't you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also it ain't getting the toolbar, it creates a new one... I think I remember disliking this function name... which reminds me, we only store the first toolbar in the manager, if we create extra toolbars they don't go here (though they do get added to the window naturally). What do you think about making the example a bit simpler with topbar = manager.new_toolbar('north')
# create new toolbar without adding it to the main window
sidebar = manager.new_toolbar()
win.add_element(sidebar, 'west') or too complicated... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to keep track of other toolbars, if you create it you have the handler. The example we can fix in other smaller PRs, at this moment it just has to work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so yes, definitely not a property for this I think... as we create a new toolbar... do you think I should rename it just for clarity? We keep it private for now so no worries about BC later if we change our mind. |
||
try: | ||
# must be inited after the window, drawingArea and figure | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
who is this manager? the last one of managers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because calling mainloop will pause execution here... we only want one to pause it once we have shown all of the managers.