########################################################################
#
#    Vision Network - Python source code - file generated by vision
#    Thursday 19 April 2007 12:55:15 
#    
#       The Scripps Research Institute (TSRI)
#       Molecular Graphics Lab
#       La Jolla, CA 92037, USA
#
# Copyright: Daniel Stoffler, Michel Sanner and TSRI
#   
# revision: Guillaume Vareille
#  
#########################################################################
#
# $Header: /opt/cvs/python/packages/share1.5/Vision/doc/Examples/matplotlib/SaveFig_net.py,v 1.2 2007/08/29 20:37:16 vareille Exp $
#
# $Id: SaveFig_net.py,v 1.2 2007/08/29 20:37:16 vareille Exp $
#

from traceback import print_exc
## loading libraries ##
from Vision.matplotlibNodes import matplotliblib
masterNet.getEditor().addLibraryInstance(matplotliblib,"Vision.matplotlibNodes", "matplotliblib")

try:
    ## saving node SinFunc ##
    from Vision.matplotlibNodes import SinFunc
    SinFunc_1 = SinFunc(constrkw = {}, name='SinFunc', library=matplotliblib)
    masterNet.addNode(SinFunc_1,128,30)
except:
    print "WARNING: failed to restore SinFunc named SinFunc in network masterNet"
    print_exc()
    SinFunc_1=None

try:
    ## saving node Plot ##
    from Vision.matplotlibNodes import PlotNE
    Plot_2 = PlotNE(constrkw = {}, name='Plot', library=matplotliblib)
    masterNet.addNode(Plot_2,147,102)
except:
    print "WARNING: failed to restore PlotNE named Plot in network masterNet"
    print_exc()
    Plot_2=None

try:
    ## saving node Figure ##
    from Vision.matplotlibNodes import MPLFigureNE
    Figure_3 = MPLFigureNE(constrkw = {}, name='Figure', library=matplotliblib)
    masterNet.addNode(Figure_3,157,160)
    Figure_3.inputPortByName['packOpts'].widget.set("{'side':'top', 'fill':'both', 'expand':1}", run=False)
except:
    print "WARNING: failed to restore MPLFigureNE named Figure in network masterNet"
    print_exc()
    Figure_3=None

try:
    ## saving node SaveFig ##
    from Vision.matplotlibNodes import SaveFig
    SaveFig_4 = SaveFig(constrkw = {}, name='SaveFig', library=matplotliblib)
    masterNet.addNode(SaveFig_4,167,223)
    SaveFig_4.inputPortByName['fname'].widget.set("plot1.png", run=False)
    apply(SaveFig_4.configure, (), {'expanded': True})
except:
    print "WARNING: failed to restore SaveFig named SaveFig in network masterNet"
    print_exc()
    SaveFig_4=None

masterNet.freeze()

## saving connections for network Network 0 ##
if SinFunc_1 is not None and Plot_2 is not None:
    try:
        masterNet.connectNodes(
            SinFunc_1, Plot_2, "y", "y", blocking=True)
    except:
        print "WARNING: failed to restore connection between SinFunc_1 and Plot_2 in network masterNet"
if Plot_2 is not None and Figure_3 is not None:
    try:
        masterNet.connectNodes(
            Plot_2, Figure_3, "plot", "plots", blocking=True)
    except:
        print "WARNING: failed to restore connection between Plot_2 and Figure_3 in network masterNet"
if Figure_3 is not None and SaveFig_4 is not None:
    try:
        masterNet.connectNodes(
            Figure_3, SaveFig_4, "figure", "figure", blocking=True)
    except:
        print "WARNING: failed to restore connection between Figure_3 and SaveFig_4 in network masterNet"
masterNet.unfreeze()
#masterNet.run()

