-
-
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 |
---|---|---|
|
@@ -74,7 +74,7 @@ class FigureManager(cbook.EventEmitter): | |
The figure number. | ||
""" | ||
def __init__(self, figure, num): | ||
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. @OceanWolf why are you getting a 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 we want to create a Also much cleaner, allowing us to get rid of 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. Not that I don't agree with you, but for consistency please check my comment about the typical three ways of getting things running. |
||
cbook.EventEmitter.__init__(self) | ||
super(FigureManager, self).__init__() | ||
self.num = num | ||
|
||
self._backend = get_backend() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,9 +391,8 @@ def stop_event_loop(self): | |
|
||
|
||
class WindowGTK3(WindowBase, Gtk.Window): | ||
def __init__(self, title): | ||
WindowBase.__init__(self, title) | ||
Gtk.Window.__init__(self) | ||
def __init__(self, title, **kwargs): | ||
super(WindowGTK3, self).__init__(title=title, **kwargs) | ||
self.set_window_title(title) | ||
|
||
try: | ||
|
@@ -829,8 +828,7 @@ def draw_rubberband(self, x0, y0, x1, y1): | |
|
||
class ToolbarGTK3(ToolContainerBase, Gtk.Box): | ||
def __init__(self, toolmanager, flow='horizontal'): | ||
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. 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. In the same way that we handle |
||
ToolContainerBase.__init__(self, toolmanager) | ||
Gtk.Box.__init__(self) | ||
super(ToolbarGTK3, self).__init__(toolmanager=toolmanager) | ||
self._toolarea = Gtk.Box() | ||
self.set_flow(flow) | ||
|
||
|
@@ -917,8 +915,7 @@ def _add_separator(self): | |
|
||
class StatusbarGTK3(StatusbarBase, Gtk.Statusbar): | ||
def __init__(self, *args, **kwargs): | ||
StatusbarBase.__init__(self, *args, **kwargs) | ||
Gtk.Statusbar.__init__(self) | ||
super(StatusbarGTK3, self).__init__(*args, **kwargs) | ||
self._context = self.get_context_id('message') | ||
|
||
def set_message(self, s): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,6 +545,7 @@ def process(self, s, *args, **kwargs): | |
|
||
class EventEmitter(object): | ||
def __init__(self): | ||
super(EventEmitter, self).__init__() | ||
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. Maybe add a brief comment as to why 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. Basically you need Do you think I should also add something about this in the developers guide? 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 have now read https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ and scanned 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. Thanks, I shall get onto it in due course, and perhaps do a bit of a clearout at the same time, as I got a bit confused last time I looked as some of it looks out of date. Doing a search for The |
||
self._callbacks = CallbackRegistry() | ||
|
||
def mpl_connect(self, s, func): | ||
|
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.
title
is getting droppedThere 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, intentionally, when working with super, one should take of arguments as and when they get used. I find this encourages good encapsulation of classes.
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.
devil's advocate: you are documenting that it accepts a title argument, and you even have a method for setting a title, but they do nothing. It is entirely misleading to me.
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, I did have the same thought last night (as I typed the message), that I probably should refactor that down now we use super...
But now checking on the other backends, and I now see I call
self.set_window_title(title)
in all the backends apart from Wx, and I don't think it hurts to call it again, so I can probably move that to here :). Fingers crossed the super magic holds (I think it will, but only 90% sure)...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 do not understand this. You should only explicitly list args/kwargs in the signature that you intend to use.
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.
It should fallback to
self.set_window_title(title)
and let that be a no-op if needed?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.
Okay, will do, I can't remember if I did this (combined with the
get_window_title
returningimage
on the base class) to satisfy a test, or whether just to avoid possible breakage with user code when they switch from using the old classes to using the new ones.Anyway, if a problem occur, then I think we can find a better way to do this.