- Timestamp:
- Jul 23, 2008, 8:00:21 PM (16 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/analyzer.tcl
r1003 r1077 203 203 "@[itcl::code $this _resultTooltip]" 204 204 205 $itk_component(resultselector) choices insert end \ 206 --- "---" 207 208 itk_component add download { 209 button $w.top.dl -image [Rappture::icon download] -anchor e \ 210 -borderwidth 1 -relief flat -overrelief raised \ 211 -command [itcl::code $this download start $w.top.dl] 212 } 213 pack $itk_component(download) -side right -padx {4 0} 214 bind $itk_component(download) <Enter> \ 215 [itcl::code $this download coming] 216 217 $itk_component(resultselector) choices insert end \ 218 @download [Rappture::filexfer::label download] 219 205 220 if {[Rappture::filexfer::enabled]} { 206 $itk_component(resultselector) choices insert end \207 --- "---"208 $itk_component(resultselector) choices insert end \209 @download "Download..."210 211 itk_component add download {212 button $w.top.dl -image [Rappture::icon download] -anchor e \213 -borderwidth 1 -relief flat -overrelief raised \214 -command [itcl::code $this download start $w.top.dl]215 }216 pack $itk_component(download) -side right -padx {4 0}217 221 Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop. From there, you can easily print or save results. 218 222 219 223 NOTE: Your web browser must allow pop-ups from this site. If your output does not appear, look for a 'pop-up blocked' message and enable pop-ups." 220 221 bind $itk_component(download) <Enter> \ 222 [itcl::code $this download coming] 224 } else { 225 Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop." 223 226 } 224 227 … … 550 553 set _plotlist "" 551 554 552 if {[Rappture::filexfer::enabled]} { 553 $itk_component(resultselector) choices insert end \ 554 --- "---" 555 $itk_component(resultselector) choices insert end \ 556 @download "Download..." 557 } 555 $itk_component(resultselector) choices insert end --- "---" 556 $itk_component(resultselector) choices insert end \ 557 @download [Rappture::filexfer::label download] 558 558 set _lastlabel "" 559 559 … … 581 581 # ---------------------------------------------------------------------- 582 582 itcl::body Rappture::Analyzer::download {option args} { 583 if {[Rappture::filexfer::enabled]} { 584 set title [$itk_component(resultselector) value] 585 set page [$itk_component(resultselector) translate $title] 586 587 switch -- $option { 588 coming { 589 # 590 # Warn result that a download is coming, in case 591 # it needs to take a screen snap. 592 # 593 if {![regexp {^(|@download|---)$} $page]} { 594 set f [$itk_component(resultpages) page $page] 595 $f.rviewer download coming 583 set title [$itk_component(resultselector) value] 584 set page [$itk_component(resultselector) translate $title] 585 586 switch -- $option { 587 coming { 588 # 589 # Warn result that a download is coming, in case 590 # it needs to take a screen snap. 591 # 592 if {![regexp {^(|@download|---)$} $page]} { 593 set f [$itk_component(resultpages) page $page] 594 $f.rviewer download coming 595 } 596 } 597 controls { 598 # no controls for this download yet 599 return "" 600 } 601 start { 602 set widget $itk_component(download) 603 if {[llength $args] > 0} { 604 set widget [lindex $args 0] 605 if {[catch {winfo class $widget}]} { 606 set widget $itk_component(download) 596 607 } 597 608 } 598 controls { 599 # no controls for this download yet 600 return "" 601 } 602 start { 603 set widget $itk_component(download) 604 if {[llength $args] > 0} { 605 set widget [lindex $args 0] 606 if {[catch {winfo class $widget}]} { 607 set widget $itk_component(download) 609 # 610 # See if this download has any controls. If so, then 611 # post them now and let the user continue the download 612 # after selecting a file format. 613 # 614 if {$page != ""} { 615 set ext "" 616 set f [$itk_component(resultpages) page $page] 617 set popup [$f.rviewer download controls \ 618 [itcl::code $this download now $widget]] 619 620 if {"" != $popup} { 621 $popup activate $widget below 622 } else { 623 download now $widget 624 } 625 } else { 626 # this shouldn't happen 627 set file error.html 628 set data "<h1>Not Found</h1>There is no result selected." 629 } 630 } 631 now { 632 set widget $itk_component(download) 633 if {[llength $args] > 0} { 634 set widget [lindex $args 0] 635 if {[catch {winfo class $widget}]} { 636 set widget $itk_component(download) 637 } 638 } 639 # 640 # Perform the actual download. 641 # 642 if {$page != ""} { 643 set ext "" 644 set f [$itk_component(resultpages) page $page] 645 foreach {ext data} [$f.rviewer download now] break 646 if {"" == $ext} { 647 if {"" != $widget} { 648 Rappture::Tooltip::cue $widget \ 649 "Can't download this result." 608 650 } 651 return 609 652 } 610 # 611 # See if this download has any controls. If so, then 612 # post them now and let the user continue the download 613 # after selecting a file format. 614 # 615 if {$page != ""} { 616 set ext "" 617 set f [$itk_component(resultpages) page $page] 618 set popup [$f.rviewer download controls \ 619 [itcl::code $this download now $widget]] 620 621 if {"" != $popup} { 622 $popup activate $widget below 623 } else { 624 download now $widget 625 } 626 } else { 627 # this shouldn't happen 628 set file error.html 629 set data "<h1>Not Found</h1>There is no result selected." 630 } 631 } 632 now { 633 set widget $itk_component(download) 634 if {[llength $args] > 0} { 635 set widget [lindex $args 0] 636 if {[catch {winfo class $widget}]} { 637 set widget $itk_component(download) 638 } 639 } 640 # 641 # Perform the actual download. 642 # 643 if {$page != ""} { 644 set ext "" 645 set f [$itk_component(resultpages) page $page] 646 foreach {ext data} [$f.rviewer download now] break 647 if {"" == $ext} { 648 if {"" != $widget} { 649 Rappture::Tooltip::cue $widget \ 650 "Can't download this result." 651 } 652 return 653 } 654 regsub -all {[\ -\/\:-\@\{-\~]} $title {} title 655 set file "$title$ext" 656 } else { 657 # this shouldn't happen 658 set file error.html 659 set data "<h1>Not Found</h1>There is no result selected." 660 } 661 662 set mesg [Rappture::filexfer::download $data $file] 663 if {[string length $mesg] > 0} { 664 Rappture::Tooltip::cue $widget $mesg 665 } 666 } 667 default { 668 error "bad option \"$option\": should be coming, controls, now, start" 669 } 653 regsub -all {[\ -\/\:-\@\{-\~]} $title {} title 654 set file "$title$ext" 655 } else { 656 # this shouldn't happen 657 set file error.html 658 set data "<h1>Not Found</h1>There is no result selected." 659 } 660 661 set mesg [Rappture::filexfer::download $data $file] 662 if {[string length $mesg] > 0} { 663 Rappture::Tooltip::cue $widget $mesg 664 } 665 } 666 default { 667 error "bad option \"$option\": should be coming, controls, now, start" 670 668 } 671 669 } -
trunk/gui/scripts/bugreport.tcl
r743 r1077 83 83 } 84 84 85 if {[Rappture::filexfer::enabled]} {86 .bugreport.details.cntls.dload configure -state normal87 } else {88 .bugreport.details.cntls.dload configure -state disabled89 }90 91 85 set w [winfo reqwidth .bugreport] 92 86 set h [winfo reqheight .bugreport] … … 180 174 # ---------------------------------------------------------------------- 181 175 proc Rappture::bugreport::download {} { 182 if {[Rappture::filexfer::enabled]} { 183 set info [.bugreport.details.info.text get 1.0 end] 184 Rappture::filexfer::download $info bugreport.txt 185 } 176 set info [.bugreport.details.info.text get 1.0 end] 177 Rappture::filexfer::download $info bugreport.txt 186 178 } 187 179 -
trunk/gui/scripts/energyLevels.tcl
r766 r1077 423 423 if {![winfo exists .energyresultdownload]} { 424 424 # if we haven't created the popup yet, do it now 425 Rappture::Balloon $popup -title "Download as..." 425 Rappture::Balloon $popup \ 426 -title "[Rappture::filexfer::label downloadWord] as..." 426 427 set inner [$popup component inner] 427 428 label $inner.summary -text "" -anchor w … … 435 436 -value pdf 436 437 pack $inner.pdf -anchor w 437 button $inner.go -text "Download Now"\438 button $inner.go -text [Rappture::filexfer::label download] \ 438 439 -command [lindex $args 0] 439 440 pack $inner.go -pady 4 … … 443 444 set num [llength [get]] 444 445 set num [expr {($num == 1) ? "1 result" : "$num results"}] 445 $inner.summary configure -text " Download$num in the following format:"446 $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:" 446 447 update idletasks ;# fix initial sizes 447 448 return $popup -
trunk/gui/scripts/filexfer.tcl
r683 r1077 66 66 # If so, then the GUI will provide "Download..." and other filexfer 67 67 # options. If not, then Rappture must be running within an 68 # environment that doesn't support it. 68 # environment that doesn't support it. As a backup, Rappture provides 69 # file load/save operations instead. 69 70 # ---------------------------------------------------------------------- 70 71 proc Rappture::filexfer::enabled {} { … … 72 73 return $enabled 73 74 } 75 76 # ---------------------------------------------------------------------- 77 # USAGE: Rappture::filexfer::label upload|download 78 # 79 # Clients use this to query the proper label for an "upload" or 80 # "download" opertion. These are usually "Upload..." and "Download", 81 # but could change to "Load File..." and "Save As..." for applications 82 # in desktop mode. 83 # ---------------------------------------------------------------------- 84 proc Rappture::filexfer::label {operation} { 85 switch -- $operation { 86 upload { 87 if {[Rappture::filexfer::enabled]} { 88 return "Upload..." 89 } else { 90 return "Load File..." 91 } 92 } 93 download { 94 if {[Rappture::filexfer::enabled]} { 95 return "Download" 96 } else { 97 return "Save As..." 98 } 99 } 100 downloadWord { 101 if {[Rappture::filexfer::enabled]} { 102 return "Download" 103 } else { 104 return "Save" 105 } 106 } 107 default { 108 error "bad option \"$operation\": should be upload, download, or downloadWord" 109 } 110 } 111 } 112 74 113 75 114 # ---------------------------------------------------------------------- … … 153 192 uplevel #0 [list $callback error $job(error)] 154 193 } 194 } else { 195 # 196 # Filexfer via importfile is disabled. This tool must be 197 # running in a desktop environment. Instead of uploading, 198 # perform a "Load File..." operation with a standard file 199 # selection dialog. 200 # 201 set i 0 202 foreach {path label desc} $controlList { 203 set file [tk_getOpenFile -title "Load File: $label"] 204 if {"" != $file} { 205 set cmds { 206 # try to read first as binary 207 set fid [open $file r] 208 fconfigure $fid -encoding binary -translation binary 209 set info [read $fid] 210 close $fid 211 if {![Rappture::encoding::is binary $info]} { 212 # not binary? then re-read and translate CR/LF 213 set fid [open $file r] 214 set info [read $fid] 215 close $fid 216 } 217 } 218 if {[catch $cmds err]} { 219 uplevel #0 [list $callback error "Error loading file [file tail $file]: $err"] 220 } else { 221 uplevel #0 [list $callback path $path data $info] 222 } 223 } 224 } 155 225 } 156 226 } … … 224 294 return $Rappture::filexfer::job(error) 225 295 } 296 } else { 297 # 298 # Filexfer via exportfile is disabled. This tool must be 299 # running in a desktop environment. Instead of downloading, 300 # perform a "Save As..." operation with a standard file 301 # selection dialog. 302 # 303 set file [tk_getSaveFile -title "Save As..." -initialfile $filename] 304 if {"" != $file} { 305 if {[catch { 306 set fid [open $file w] 307 if {[Rappture::encoding::is binary $string]} { 308 fconfigure $fid -encoding binary -translation binary 309 puts -nonewline $fid $string 310 } else { 311 puts $fid $string 312 } 313 close $fid 314 } result]} { 315 return $result 316 } 317 } 226 318 } 227 319 return "" -
trunk/gui/scripts/historesult.tcl
r878 r1077 429 429 if {![winfo exists .histogram_result_download]} { 430 430 # if we haven't created the popup yet, do it now 431 Rappture::Balloon $popup -title " Downloadas..."431 Rappture::Balloon $popup -title "[Rappture::filexfer::label downloadWord] as..." 432 432 set inner [$popup component inner] 433 433 label $inner.summary -text "" -anchor w … … 441 441 -value pdf 442 442 pack $inner.pdf -anchor w 443 button $inner.go -text "Download Now"\443 button $inner.go -text [Rappture::filexfer::label download] \ 444 444 -command [lindex $args 0] 445 445 pack $inner.go -pady 4 … … 449 449 set num [llength [get]] 450 450 set num [expr {($num == 1) ? "1 result" : "$num results"}] 451 $inner.summary configure -text " Download$num in the following format:"451 $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:" 452 452 update idletasks ;# fix initial sizes 453 453 return $popup -
trunk/gui/scripts/loader.tcl
r746 r1077 121 121 } 122 122 if {[llength $_uppath] > 0} { 123 $itk_component(combo) choices insert end @upload "Upload..." 123 $itk_component(combo) choices insert end \ 124 @upload [Rappture::filexfer::label upload] 124 125 } 125 126 … … 130 131 # 131 132 Rappture::Balloon $itk_component(hull).download \ 132 -title "Choose what to download:"133 -title "Choose what to [string tolower [Rappture::filexfer::label downloadWord]]:" 133 134 set inner [$itk_component(hull).download component inner] 134 135 … … 149 150 } 150 151 } 151 button $inner.go -text "Download"\152 button $inner.go -text [Rappture::filexfer::label download] \ 152 153 -command [itcl::code $this _downloadValues] 153 154 pack $inner.go -side bottom -padx 50 -pady {4 2} 154 155 155 156 if {[llength $_dnpaths] > 0} { 156 $itk_component(combo) choices insert end @download "Download..." 157 $itk_component(combo) choices insert end \ 158 @download [Rappture::filexfer::label download] 157 159 } 158 160 … … 304 306 set obj [$itk_component(combo) translate $newval] 305 307 if {$obj == "@upload"} { 306 if {[Rappture::filexfer::enabled]} { 307 set tool [Rappture::Tool::resources -appname] 308 Rappture::filexfer::upload \ 309 $tool $_uppath [itcl::code $this _uploadValue] 310 } 308 set tool [Rappture::Tool::resources -appname] 309 Rappture::filexfer::upload \ 310 $tool $_uppath [itcl::code $this _uploadValue] 311 311 312 312 # put the combobox back to its last value … … 417 417 418 418 set mesg "" 419 if {[Rappture::filexfer::enabled]} { 420 foreach path $_dnpaths { 421 if {$_dnpath2state($this-$path)} { 422 set info [$itk_option(-tool) valuefor $path] 423 set mesg [Rappture::filexfer::download $info input.txt] 424 if {"" != $mesg} { break } 425 } 419 foreach path $_dnpaths { 420 if {$_dnpath2state($this-$path)} { 421 set info [$itk_option(-tool) valuefor $path] 422 set mesg [Rappture::filexfer::download $info input.txt] 423 if {"" != $mesg} { break } 426 424 } 427 425 } -
trunk/gui/scripts/numberresult.tcl
r768 r1077 489 489 if {![winfo exists .xyresultdownload]} { 490 490 # if we haven't created the popup yet, do it now 491 Rappture::Balloon $popup -title " Downloadas..."491 Rappture::Balloon $popup -title "[Rappture::filexfer::label downloadWord] as..." 492 492 set inner [$popup component inner] 493 493 label $inner.summary -text "" -anchor w … … 501 501 -value pdf 502 502 pack $inner.pdf -anchor w 503 button $inner.go -text "Download Now"\503 button $inner.go -text [Rappture::filexfer::label download] \ 504 504 -command [lindex $args 0] 505 505 pack $inner.go -pady 4 … … 509 509 set num [llength [get]] 510 510 set num [expr {($num == 1) ? "1 result" : "$num results"}] 511 $inner.summary configure -text " Download$num in the following format:"511 $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:" 512 512 update idletasks ;# fix initial sizes 513 513 return $popup -
trunk/gui/scripts/textentry.tcl
r724 r1077 311 311 $itk_component(tmenu) add command -label "Select All" -accelerator "^A" -command [list $itk_component(text) tag add sel 1.0 end] 312 312 $itk_component(tmenu) add separator 313 $itk_component(tmenu) add command -label "Upload..." \ 313 314 $itk_component(tmenu) add command \ 315 -label [Rappture::filexfer::label upload] \ 314 316 -command [itcl::code $this _uploadValue -start] 315 $itk_component(tmenu) add command -label "Download" \ 317 $itk_component(tmenu) add command \ 318 -label [Rappture::filexfer::label download] \ 316 319 -command [itcl::code $this _downloadValue] 320 317 321 bind $itk_component(text) <<PopupMenu>> \ 318 322 [itcl::code $this _edit menu tmenu %X %Y] -
trunk/gui/scripts/xyresult.tcl
r1040 r1077 430 430 if {![winfo exists .xyresultdownload]} { 431 431 # if we haven't created the popup yet, do it now 432 Rappture::Balloon $popup -title " Downloadas..."432 Rappture::Balloon $popup -title "[Rappture::filexfer::label downloadWord] as..." 433 433 set inner [$popup component inner] 434 434 label $inner.summary -text "" -anchor w … … 442 442 -value pdf 443 443 pack $inner.pdf -anchor w 444 button $inner.go -text "Download Now"\444 button $inner.go -text [Rappture::filexfer::label download] \ 445 445 -command [lindex $args 0] 446 446 pack $inner.go -pady 4 … … 450 450 set num [llength [get]] 451 451 set num [expr {($num == 1) ? "1 result" : "$num results"}] 452 $inner.summary configure -text " Download$num in the following format:"452 $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:" 453 453 update idletasks ;# fix initial sizes 454 454 return $popup
Note: See TracChangeset
for help on using the changeset viewer.