source: trunk/examples/graph/graph.py @ 3075

Last change on this file since 3075 was 711, checked in by mmc, 17 years ago

Fixed the older MoleculeViewer? to work properly with the add/delete
calls needed for the new PyMol?-based viewer.

Disabled the syncCutBuffer stuff in mainwin that used to be used for
copy/paste with desktop. This never worked very well, and we have
the newer upload/download stuff in place now.

A few small tweaks to the graph example and the loader example.

File size: 1.2 KB
Line 
1# ----------------------------------------------------------------------
2#  GRAPH
3#
4#  This simple example shows how you can use the Rappture toolkit
5#  to handle I/O for a simple simulator--in this case, one that
6#  evaluates an x/y graph
7#
8# ======================================================================
9#  AUTHOR:  Michael McLennan, Purdue University
10#  Copyright (c) 2004-2005  Purdue Research Foundation
11#
12#  See the file "license.terms" for information on usage and
13#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14# ======================================================================
15
16import Rappture
17import sys
18from math import *
19
20io = Rappture.library(sys.argv[1])
21
22xmin = float(io.get('input.number(min).current'))
23xmax = float(io.get('input.number(max).current'))
24formula = io.get('input.string(formula).current')
25print 'formula = %s' % formula
26npts = 100
27
28io.put('output.curve(result).about.label','Formula: Y vs X',append=0)
29io.put('output.curve(result).yaxis.label','Y')
30io.put('output.curve(result).xaxis.label','X')
31
32for i in range(npts):
33    x = (xmax-xmin)/npts * i + xmin;
34    y = eval(formula)
35    io.put('output.curve(result).component.xy', '%g %g\n' % (x,y), append=1)
36
37Rappture.result(io)
Note: See TracBrowser for help on using the repository browser.