source: trunk/builder/scripts/templates/tcl.tl

Last change on this file was 3181, checked in by ldelgass, 12 years ago

Tcl skeleton code generated from builder needs Img package for image inputs/outputs

File size: 3.2 KB
RevLine 
[2147]1# ----------------------------------------------------------------------
2#  LANGUAGE:  Tcl API
3# ======================================================================
4#  AUTHOR:  Michael McLennan, Purdue University
[3177]5#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
[2147]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" {
[2153]11  extension ".tcl"
12  command {tclsh @tool/@@FILENAME@@ @driver}
13
[2147]14  main {# ----------------------------------------------------------------------
15#  MAIN PROGRAM - generated by the Rappture Builder
16# ----------------------------------------------------------------------
17package require Rappture
[3181]18package require Img
[2147]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
[2153]28#########################################################
[2147]29#  Add your code here for the main body of your program
[2153]30#########################################################
[2147]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 {
[2153]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\]"
[2147]51  }
52  input image {
[2153]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\]"
[2147]57  }
58  input number {
59    set units [attr get units]
60    if {$units ne ""} {
[2153]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\]"
[2147]64    } else {
[2153]65      code "\n# get input value for $path"
66      code "set $id \[\$io get $path.current\]"
[2147]67    }
68  }
69  input * {
[2153]70    code "\n# get input value for $path"
71    code "set $id \[\$io get $path.current\]"
[2147]72  }
73
74  output curve {
[2153]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\""
[2147]78  }
79  output histogram {
[2153]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\""
[2147]84  }
85  output image {
[2153]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\]"
[2147]89  }
90  output * {
[2153]91    code "\n# save output value for $path"
[3180]92    code "\$io put $path.current \$$id"
[2147]93  }
94}
Note: See TracBrowser for help on using the repository browser.