-
-
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 |
---|---|---|
|
@@ -1656,7 +1656,61 @@ def __init__(self, name, canvas, key, x=0, y=0, guiEvent=None): | |
self.key = key | ||
|
||
|
||
class FigureCanvasBase(object): | ||
class ExpandableBase(object): | ||
""" | ||
Base class for GUI elements that can expand to fill the area given to them | ||
by the encapsulating container (e.g. the main window). | ||
|
||
At the moment this class does not do anything apart from mark such classes, | ||
but this may well change at a later date, PRs welcome. | ||
""" | ||
pass | ||
|
||
class FlowBase(object): | ||
""" | ||
Base mixin class for all GUI elements that can flow, aka laid out in | ||
different directions. | ||
|
||
The MPL window class deals with the manipulation of this mixin, so users | ||
don't actually need to interact with this class. | ||
|
||
Classes the implement this class must override the _update_flow method. | ||
""" | ||
flow_types = ['horizontal', 'vertical'] | ||
|
||
def __init__(self, flow='horizontal', flow_locked=False, **kwargs): | ||
super(FlowBase, self).__init__(**kwargs) | ||
self.flow_locked = flow_locked | ||
self.flow = flow | ||
|
||
@property | ||
def flow(self): | ||
""" | ||
The direction of flow, one of the strings in `flow_type`. | ||
""" | ||
return FlowBase.flow_types[self._flow] | ||
|
||
@flow.setter | ||
def flow(self, flow): | ||
if self.flow_locked: | ||
return | ||
|
||
try: | ||
self._flow = FlowBase.flow_types.index(flow) | ||
except ValueError: | ||
raise ValueError('Flow (%s), not in list %s' % (flow, FlowBase.flow_types)) | ||
|
||
self._update_flow() | ||
|
||
def _update_flow(self): | ||
""" | ||
Classes that extend FlowBase must override this method. | ||
You can use the internal property self._flow whereby | ||
flow_types[self._flow] gives the current flow. | ||
""" | ||
raise NotImplementedError | ||
|
||
class FigureCanvasBase(ExpandableBase): | ||
""" | ||
The canvas the figure renders into. | ||
|
||
|
@@ -2717,7 +2771,7 @@ def set_window_title(self, title): | |
""" | ||
pass | ||
|
||
def add_element(self, element, expand, place): | ||
def add_element(self, element, place): | ||
""" Adds a gui widget to the window. | ||
This has no effect for non-GUI backends and properties only apply | ||
to those backends that support them, or have a suitable workaround. | ||
|
@@ -2726,9 +2780,6 @@ def add_element(self, element, expand, place): | |
---------- | ||
element : A gui element. | ||
The element to add to the window | ||
expand : bool | ||
Whether the element should auto expand to fill as much space within | ||
the window as possible. | ||
place : string | ||
The location to place the element, either compass points north, | ||
east, south, west, or center. | ||
|
@@ -3479,51 +3530,6 @@ def remove_toolitem(self, name): | |
raise NotImplementedError | ||
|
||
|
||
class FlowBase(object): | ||
""" | ||
Base mixin class for all GUI elements that can flow, aka laid out in | ||
different directions. | ||
|
||
The MPL window class deals with the manipulation of this mixin, so users | ||
don't actually need to interact with this class. | ||
|
||
Classes the implement this class must override the _update_flow method. | ||
""" | ||
flow_types = ['horizontal', 'vertical'] | ||
|
||
def __init__(self, flow='horizontal', flow_locked=False, **kwargs): | ||
super(FlowBase, self).__init__(**kwargs) | ||
self.flow_locked = flow_locked | ||
self.flow = flow | ||
|
||
@property | ||
def flow(self): | ||
""" | ||
The direction of flow, one of the strings in `flow_type`. | ||
""" | ||
return FlowBase.flow_types[self._flow] | ||
|
||
@flow.setter | ||
def flow(self, flow): | ||
if self.flow_locked: | ||
return | ||
|
||
try: | ||
self._flow = FlowBase.flow_types.index(flow) | ||
except ValueError: | ||
raise ValueError('Flow (%s), not in list %s' % (flow, FlowBase.flow_types)) | ||
|
||
self._update_flow() | ||
|
||
def _update_flow(self): | ||
""" | ||
Classes that extend FlowBase must override this method. | ||
You can use the internal property self._flow whereby | ||
flow_types[self._flow] gives the current flow. | ||
""" | ||
raise NotImplementedError | ||
|
||
|
||
class ToolbarBase(ToolContainerBase, FlowBase): | ||
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. Shouldn't this be expandable? 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. Nope, the |
||
pass | ||
|
||
|
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.
Why not just a attribute in the
ContainerBase
? right now I don't see any use other than marking.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.
This goes on
FigureCanvasBase
not onToolContainerBase
. The figcanvas expands to fill all available room, the toolbar does not. A toolbar should stay as a "bar" 😉.Right now I agree it looks simpler to just add this as a property to
FigureCanvasBase
, but in the longer term I think it better and easier to start like this, and I say that for two reasons:FigureCanvasBase
(and other classes we might have latter set this attribute on), but also all of the backends.For these reasons I think it best to start of with clear readable and maintainable code, even if it feels like overkill right now.