-
-
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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
""" | ||
`FigureManager` | ||
Class that pulls all of the standard GUI elements together, and manages | ||
the interaction between them. | ||
|
||
`ToolManager` | ||
Class that makes the bridge between user interaction (key press, | ||
toolbar clicks, ..) and the actions in response to the user inputs. | ||
|
@@ -86,7 +90,17 @@ def __init__(self, figure, num): | |
|
||
self.window.add_element_to_window(self.canvas, True, True, 0, 'center') | ||
|
||
self.toolmanager = self._get_toolmanager() | ||
self.toolbar = self._get_toolbar() | ||
|
||
if self.toolmanager: | ||
tools.add_tools_to_manager(self.toolmanager) | ||
if self.toolbar: | ||
tools.add_tools_to_container(self.toolbar) | ||
self.statusbar = self._backend.Statusbar(self.toolmanager) | ||
h += self.window.add_element_to_window(self.statusbar, False, | ||
False, 0, 'south') | ||
|
||
if self.toolbar is not None: | ||
h += self.window.add_element_to_window(self.toolbar, | ||
False, False, 0, 'south') | ||
|
@@ -98,7 +112,7 @@ def __init__(self, figure, num): | |
|
||
def notify_axes_change(fig): | ||
'this will be called whenever the current axes is changed' | ||
if self.toolbar is not None: | ||
if self.toolmanager is None and self.toolbar is not None: | ||
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. Do we need the add_axobserver? it is already handled by toolmanager and as far as I know MEP27 is going to be used exclusively with toolmanager. |
||
self.toolbar.update() | ||
self.canvas.figure.add_axobserver(notify_axes_change) | ||
|
||
|
@@ -157,12 +171,22 @@ def set_window_title(self, title): | |
def _get_toolbar(self): | ||
# must be inited after the window, drawingArea and figure | ||
# attrs are set | ||
if rcParams['toolbar'] == 'toolbar2': | ||
if rcParams['toolbar'] == 'toolmanager': | ||
toolbar = self._backend.Toolbar(self.toolmanager) | ||
elif rcParams['toolbar'] == 'toolbar2': | ||
toolbar = self._backend.Toolbar2(self.canvas, self.window) | ||
else: | ||
toolbar = None | ||
return toolbar | ||
|
||
def _get_toolmanager(self): | ||
# must be initialised after toolbar has been setted | ||
if rcParams['toolbar'] != 'toolbar2': | ||
toolmanager = ToolManager(self.canvas) | ||
else: | ||
toolmanager = None | ||
return toolmanager | ||
|
||
def show_popup(self, msg): | ||
""" | ||
Display message in a popup -- GUI only | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,6 +385,10 @@ def stop_event_loop(self): | |
FigureCanvasBase.stop_event_loop_default(self) | ||
stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__ | ||
|
||
|
||
_flow = [Gtk.Orientation.HORIZONTAL, Gtk.Orientation.VERTICAL] | ||
|
||
|
||
class Window(WindowBase, Gtk.Window): | ||
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 don't keep the name something like 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. Personally, I don't really see what difference it makes apart from taking up extra hard drive and memory space. At the moment we have I don't mind renaming it, I just don't see any need for it... 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 kind of agree with you, but in that case, why don't we remove all 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. 👍 On making the GUI specific classes have the framework name in them and doing 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 guess "bad" beats "ugly" (ugly in terms of a list of housekeeping aliases at end of each file. I can't imagine how it could get bad, (on the other hand I found debugging that transform logic a nightmare with multiple layers of transforms to go through and understand what they what they were doing and why they were failing), so meh. |
||
def __init__(self, title): | ||
WindowBase.__init__(self, title) | ||
|
@@ -426,14 +430,19 @@ def _setup_box(self, name, orientation, grow, parent): | |
|
||
def add_element_to_window(self, element, expand, fill, pad, place): | ||
element.show() | ||
|
||
flow = _flow[not _flow.index(self._layout[place].get_orientation())] | ||
separator = Gtk.Separator(orientation=flow) | ||
if place in ['north', 'west', 'center']: | ||
self._layout[place].pack_start(element, expand, fill, pad) | ||
self._layout[place].pack_start(separator, False, False, 0) | ||
elif place in ['south', 'east']: | ||
self._layout[place].pack_end(element, expand, fill, pad) | ||
self._layout[place].pack_end(separator, False, False, 0) | ||
else: | ||
raise KeyError('Unknown value for place, %s' % place) | ||
size_request = element.size_request() | ||
return size_request.height | ||
return size_request.height + separator.size_request().height | ||
|
||
def set_default_size(self, width, height): | ||
Gtk.Window.set_default_size(self, width, height) | ||
|
@@ -1047,5 +1056,6 @@ def error_msg_gtk(msg, parent=None): | |
backend_tools.ToolRubberband = RubberbandGTK3 | ||
|
||
Toolbar = ToolbarGTK3 | ||
Statusbar = StatusbarGTK3 | ||
FigureCanvas = FigureCanvasGTK3 | ||
FigureManager = FigureManagerGTK3 |
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.
How will this ever not be True?
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.
Good question, atm another leftover relic, but talk over in OceanWolf#4 about perhaps adding a rcParam for this. Tl;dr @fariza refers to a discussion some time ago about that sees adding keyboard shortcuts without an rcParam as a bug, but we have had this as default behaviour (pre MEP22) for quite some time.
I think we both feel happy about removing this now and discussing rcParams later, right @fariza?
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 agree, everything is in the right place to add those rcParams later and just modify the FigureManager class