本文整理汇总了Python中matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg.get_realized方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTK3Agg.get_realized方法的具体用法?Python FigureCanvasGTK3Agg.get_realized怎么用?Python FigureCanvasGTK3Agg.get_realized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg
的用法示例。
在下文中一共展示了FigureCanvasGTK3Agg.get_realized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainPlotController
# 需要导入模块: from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg [as 别名]
# 或者: from matplotlib.backends.backend_gtk3agg.FigureCanvasGTK3Agg import get_realized [as 别名]
class MainPlotController(object):
"""
A controller for the main plot canvas.
Sets up the widgets and has image exporting functionality.
"""
file_filters = ("Portable Network Graphics (PNG)", "*.png"), \
("Scalable Vector Graphics (SVG)", "*.svg"), \
("Portable Document Format (PDF)", "*.pdf")
_canvas = None
@property
def canvas(self):
if not self._canvas:
self.setup_figure()
self.setup_canvas()
self.setup_content()
return self._canvas
# ------------------------------------------------------------
# View integration getters
# ------------------------------------------------------------
def get_toolbar_widget(self, window):
return NavigationToolbar(self.canvas, window)
def get_canvas_widget(self):
return self.canvas
# ------------------------------------------------------------
# Initialization and other internals
# ------------------------------------------------------------
def __init__(self, status_callback, marker_callback, *args, **kwargs):
self.setup_layout_cache()
self.setup_figure()
self.setup_canvas()
self.setup_content(status_callback, marker_callback)
def setup_layout_cache(self):
self.position_setup = PositionSetup()
self.labels = list()
self.marker_lbls = list()
self._proxies = dict()
self.scale = 1.0
self.stats = False
self._last_pos = None
def setup_figure(self):
self.figure = Figure(dpi=72, facecolor="#FFFFFF", linewidth=0)
self.figure.subplots_adjust(hspace=0.0, wspace=0.0)
def setup_canvas(self):
self._canvas = FigureCanvasGTK(self.figure)
def setup_content(self, status_callback, marker_callback):
# Create subplot and add it to the figure:
self.plot = Subplot(self.figure, 211, facecolor=(1.0, 1.0, 1.0, 0.0))
self.plot.set_autoscale_on(False)
self.figure.add_axes(self.plot)
# Connect events:
self.canvas.mpl_connect('draw_event', self.fix_after_drawing)
self.canvas.mpl_connect('resize_event', self.fix_after_drawing)
self.mtc = MotionTracker(self, status_callback)
self.cc = ClickCatcher(self, marker_callback)
#self.update()
# ------------------------------------------------------------
# Update methods
# ------------------------------------------------------------
def draw(self):
self._last_pos = self.fix_before_drawing()
self.figure.canvas.draw()
def fix_after_drawing(self, *args):
_new_pos = self.fix_before_drawing()
if _new_pos != self._last_pos:
self.figure.canvas.draw()
self._last_pos = _new_pos
return False
def fix_before_drawing(self, *args):
"""
Fixes alignment issues due to longer labels or smaller windows
Is executed after an initial draw event, since we can then retrieve
the actual label dimensions and shift/resize the plot accordingly.
"""
renderer = get_renderer(self.figure)
if not renderer or not self._canvas.get_realized():
return False
# Fix left side for wide specimen labels:
if len(self.labels) > 0:
bbox = self._get_joint_bbox(self.labels, renderer)
if bbox is not None:
self.position_setup.left = self.position_setup.default_left + bbox.width
# Fix top for high marker labels:
#.........这里部分代码省略.........