source: branches/blt4/builder/scripts/templates/tcl.tl @ 3959

Last change on this file since 3959 was 3959, checked in by gah, 11 years ago

sync with trunk

File size: 3.2 KB
Line 
1# ----------------------------------------------------------------------
2#  LANGUAGE:  Tcl API
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
6#
7#  See the file "license.terms" for information on usage and
8#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9# ======================================================================
10language "Tcl" {
11  extension ".tcl"
12  command {tclsh @tool/@@FILENAME@@ @driver}
13
14  main {# ----------------------------------------------------------------------
15#  MAIN PROGRAM - generated by the Rappture Builder
16# ----------------------------------------------------------------------
17package require Rappture
18package require Img
19
20# open the XML file containing the run parameters
21set io [Rappture::library [lindex $argv 0]]
22
23#########################################################
24# Get input values from Rappture
25#########################################################
26@@INPUTS@@
27
28#########################################################
29#  Add your code here for the main body of your program
30#########################################################
31
32# spit out progress messages as you go along...
33Rappture::Utils::progress 0 -mesg "Starting..."
34Rappture::Utils::progress 5 -mesg "Loading data..."
35Rappture::Utils::progress 50 -mesg "Half-way there"
36Rappture::Utils::progress 100 -mesg "Done"
37
38#########################################################
39# Save output values back to Rappture
40#########################################################
41@@OUTPUTS@@
42
43Rappture::result $io
44exit 0
45}
46
47  input boolean {
48    code "\n# get input value for $path"
49    code "# returns value as string \"yes\" or \"no\""
50    code "set $id \[\$io get $path.current\]"
51  }
52  input image {
53    code "\n# get input value for $path"
54    code "# returns base64-encoded image data"
55    code "set imdata \[\$io get $path.current\]"
56    code "set $id \[image create photo -data \$imdata\]"
57  }
58  input number {
59    set units [attr get units]
60    if {$units ne ""} {
61      code "\n# get input value for $path and convert to $units"
62      code "set str \[\$io get $path.current\]"
63      code "set $id \[Rappture::Units::convert \$str -to $units -units off\]"
64    } else {
65      code "\n# get input value for $path"
66      code "set $id \[\$io get $path.current\]"
67    }
68  }
69  input * {
70    code "\n# get input value for $path"
71    code "set $id \[\$io get $path.current\]"
72  }
73
74  output curve {
75    code "\n# save output value for $path"
76    code "# this shows just one (x,y) point -- modify as needed"
77    code "\$io put -append yes $path.component.xy \"\$x \$y\\n\""
78  }
79  output histogram {
80    code "\n# save output value for $path"
81    code "# this shows just one point -- modify as needed"
82    code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)"
83    code "\$io put -append yes $path.component.xy \"\$x \$h \$w\\n\""
84  }
85  output image {
86    code "\n# save output value for $path"
87    code "# this assumes that \$imh is the handle for a Tk photo image"
88    code "\$io put $path.current \[\$imh data -format gif\]"
89  }
90  output * {
91    code "\n# save output value for $path"
92    code "\$io put $path.current \$$id"
93  }
94}
Note: See TracBrowser for help on using the repository browser.