This repository has been archived by the owner on May 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the MPLCanvas pr for merge with master
- Loading branch information
Showing
4 changed files
with
235 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,46 @@ | ||
#------------------------------------------------------------------------------ | ||
# Copyright (c) 2011, Enthought, Inc. | ||
# Copyright (c) 2012, Enthought, Inc. | ||
# All rights reserved. | ||
# | ||
# Special thanks to Steven Silvester for contributing this module! | ||
#------------------------------------------------------------------------------ | ||
from traits.api import Instance | ||
# NOTE: There shall be no imports from matplotlib in this module. Doing so | ||
# will create an import dependency on matplotlib for the rest of Enaml! | ||
from traits.api import Instance, Bool | ||
|
||
from .control import Control | ||
|
||
|
||
class MPLCanvas(Control): | ||
""" A control to display a Matplotlib Canvas | ||
""" A control which can be used to embded a matplotlib figure. | ||
""" | ||
#: The figure | ||
#: The matplotlib figure to display in the widget. | ||
figure = Instance('matplotlib.figure.Figure') | ||
|
||
#: How strongly a component hugs it's contents'. | ||
# MPLCanvas' ignore the hug by default, | ||
# so they expand freely in width and height. | ||
#: Whether or not the matplotlib figure toolbar is visible. | ||
toolbar_visible = Bool(False) | ||
|
||
#: Matplotlib figures expand freely in height and width by default. | ||
hug_width = 'ignore' | ||
hug_height = 'ignore' | ||
|
||
#-------------------------------------------------------------------------- | ||
# Initialization | ||
#-------------------------------------------------------------------------- | ||
def snapshot(self): | ||
""" Returns the dict of creation attributes for the control. | ||
""" Get the snapshot dict for the MPLCanvas. | ||
""" | ||
snap = super(MPLCanvas, self).snapshot() | ||
snap['figure'] = self.figure | ||
snap['toolbar_visible'] = self.toolbar_visible | ||
return snap | ||
|
||
def bind(self): | ||
""" A method called after initialization which allows the widget | ||
to bind any event handlers necessary. | ||
""" Bind the change handlers for the MPLCanvas. | ||
""" | ||
super(MPLCanvas, self).bind() | ||
self.publish_attributes('figure') | ||
self.publish_attributes('figure', 'toolbar_visible') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.