Ignore:
Timestamp:
Feb 19, 2006, 8:10:19 PM (19 years ago)
Author:
mmc
Message:
  • Added "Upload..." capability to the <loader> widget. You can now add an <upload> directive containing the path of the control that will receive data. A file is uploaded from the desktop and saved in the specified control.
  • Fixed download capability to work properly for all result types, including contour plots and molecules.
  • Added rappture::signal so we can catch SIGHUP and clean up the upload/download spool directory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/imageresult.tcl

    r132 r193  
    1414package require Itk
    1515package require BLT
     16package require Img
    1617
    1718option add *ImageResult.width 3i widgetDefault
     
    5657    public method delete {args}
    5758    public method scale {args}
    58     public method download {}
     59    public method download {option}
    5960
    6061    protected method _rebuild {args}
     
    289290
    290291# ----------------------------------------------------------------------
    291 # USAGE: download
     292# USAGE: download coming
     293# USAGE: download now
    292294#
    293295# Clients use this method to create a downloadable representation
     
    296298# "string" is the data itself.
    297299# ----------------------------------------------------------------------
    298 itcl::body Rappture::ImageResult::download {} {
    299     set top [_topimage]
    300     if {$top == ""} {
    301         return ""
    302     }
    303     return [list jpg [image data $top -format jpg]]
     300itcl::body Rappture::ImageResult::download {option} {
     301    switch $option {
     302        coming {
     303            # nothing to do
     304        }
     305        now {
     306            set top [_topimage]
     307            if {$top == ""} {
     308                return ""
     309            }
     310
     311            #
     312            # Hack alert!  Need data in binary format,
     313            # so we'll save to a file and read it back.
     314            #
     315            set tmpfile /tmp/image[pid].jpg
     316            $top write $tmpfile -format jpeg
     317            set fid [open $tmpfile r]
     318            fconfigure $fid -encoding binary -translation binary
     319            set bytes [read $fid]
     320            close $fid
     321            file delete -force $tmpfile
     322
     323            return [list .jpg $bytes]
     324        }
     325        default {
     326            error "bad option \"$option\": should be coming, now"
     327        }
     328    }
    304329}
    305330
Note: See TracChangeset for help on using the changeset viewer.