-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Dedupe window-title setting by moving it to FigureManagerBase. #15212
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
Conversation
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.
I'm feeling slightly uncomforable that FigureManagerBase.__init__
now relies on subclasses having set the window
attribute already. In fact, wouldn't that break external figure managers?
Probably the better and more explicit way would be to have a FigureManagerBase.post_init()
that set's the window title and let all backends call that.
Alternatively, we could pass the window to FigureManagerBase.__init__
and set the attribute there.
Technically this only requires that set_window_title works by the time the base class init is called, but sure. We could wrap the call to set_window_title in the base class into a try... except and emit a deprecation warning if an exception is raised, to handle the case of third-party managers. A quick look shows that this would not affect either ipython's inline backend or pycharm's interagg backend, though, as they don't touch any of these.
That seems to make the coupling even worse, IMO.
I think that also breaks backcompat, and actually also break third-party backends as soon as they pass parameters up to the super class, regardless of whether this mattered to them? Also note that noninteractive backends have no notion of "window". |
Try except + documenting that Either the base class should take full ownership and API responsibility for the window or none at all; i.e. either both define Is there any reason not to do
if you really don't want |
No, because if you're on an old-style class that doesn't allow this pattern, then that class was in charge of calling set_window_title itself anyways. (The point is to later get rid of the try except and error out if a subclass doesn't allow this.)
Because set_window_title is defined in the base class, so that doesn't work anyways. Actually '.window' is not an attribute we document to be present and indeed for example FigureManagerMac has no such attribute. |
743fc36
to
b042b68
Compare
b042b68
to
ef584e5
Compare
rebased |
... by moving it to FigureManagerBase.
ef584e5
to
b059d78
Compare
I have verified that this works on the MacOSX backend on my machine, Catalina, 10.15.7. I can change the window title with, for example, |
PR Summary
Probably someone on macOS should check that this works on the macos backend.
PR Checklist