Logo Search packages:      
Sourcecode: matplotlib version File versions  Download package


from __future__ import division 


 A wxPython backend for Agg.  This uses the GUI widgets written by
 Jeremy O'Donoghue (jeremy@o-donoghue.com) and the Agg backend by John
 Hunter (jdhunter@ace.bsd.uchicago.edu)

 Copyright (C) Jeremy O'Donoghue & John Hunter, 2003-4
 License: This work is licensed under the matplotlib license( PSF
 compatible). A copy should be included with this source code.


import sys, os, os.path, math, StringIO
from backend_agg import FigureCanvasAgg

from backend_wx import FigureManager
from backend_wx import FigureManagerWx, FigureCanvasWx, FigureFrameWx, \
     DEBUG_MSG, NavigationToolbar2Wx
from backend_wx import error_msg_wx, draw_if_interactive, show, Toolbar, \
import backend_wx

from matplotlib.figure import Figure
from matplotlib import rcParams
import matplotlib
import wx

class FigureFrameWxAgg(FigureFrameWx):

    def get_canvas(self, fig):
        return FigureCanvasWxAgg(self, -1, fig)

    def _get_toolbar(self, statbar):
        if matplotlib.rcParams['toolbar']=='classic':
            toolbar = NavigationToolbarWx(self.canvas, True)
        elif matplotlib.rcParams['toolbar']=='toolbar2':
            toolbar = NavigationToolbar2WxAgg(self.canvas)
            toolbar = None
        return toolbar 
00049 class FigureCanvasWxAgg(FigureCanvasWx,FigureCanvasAgg):
    The FigureCanvas contains the figure and does event handling.
    In the wxPython backend, it is derived from wxPanel, and (usually)
    lives inside a frame instantiated by a FigureManagerWx. The parent
    window probably implements a wxSizer to control the displayed
    control size - but we give a hint as to our preferred minimum

00061     def draw(self):
        Render the figure using agg
        DEBUG_MSG("draw()", 1, self)
        s = self.tostring_rgb()  
        w = int(self.renderer.width)
        h = int(self.renderer.height)
        image = wx.EmptyImage(w,h)
        self.bitmap = image.ConvertToBitmap()

00076     def print_figure(self, filename, dpi=150, facecolor='w',
                     edgecolor='w', orientation='portrait'):

        Render the figure to hardcopy
        agg = self.switch_backends(FigureCanvasAgg)
        agg.print_figure(filename, dpi, facecolor, edgecolor, orientation)

    def _get_imagesave_wildcards(self):
        'return the wildcard string for the filesave dialog'
        return "PS (*.ps)|*.ps|"     \
               "EPS (*.eps)|*.eps|"  \
               "SVG (*.svg)|*.svg|"  \
               "BMP (*.bmp)|*.bmp|"  \
               "PNG (*.png)|*.png"  \

class NavigationToolbar2WxAgg(NavigationToolbar2Wx):
    def get_canvas(self, frame, fig):
        return FigureCanvasWxAgg(frame, -1, fig)

def new_figure_manager(num, *args, **kwargs):
    Create a new figure manager instance
    # in order to expose the Figure constructor to the pylab
    # interface we need to create the figure here
    DEBUG_MSG("new_figure_manager()", 3, None)

    if backend_wx.wxapp is None:
        backend_wx.wxapp = wx.GetApp()
        if backend_wx.wxapp is None:
            backend_wx.wxapp = wx.PySimpleApp()
    fig = Figure(*args, **kwargs)
    frame = FigureFrameWxAgg(num, fig)
    figmgr = frame.get_figure_manager()
    if matplotlib.is_interactive():
    return figmgr

Generated by  Doxygen 1.6.0   Back to index