Changeset 2294


Ignore:
Timestamp:
Jul 5, 2011, 2:41:41 PM (13 years ago)
Author:
gah
Message:
 
Location:
branches/blt4/builder/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/builder/scripts/main.tcl

    r2275 r2294  
    323323
    324324# ----------------------------------------------------------------------
    325 # USAGE: main_errors
     325# USAGE: main_errors ?-strict?
    326326#
    327327# Checks the values of all objects in the tree to look for errors
    328 # before previewing and saving.  If any errors are found, the user
    329 # is prompted to look at them, and they can be popped up in a viewer
    330 # above the object tree.
    331 # ----------------------------------------------------------------------
    332 proc main_errors {} {
     328# before previewing and saving.  If any errors are found and the
     329# -strict flag is set, the user is forced to look at them before
     330# continuing on.  Otherwise, the user may choose to look at warnings
     331# and errors before continuing.  Usually called before previewing
     332# and saving the tool definition.  Returns 1 if there are errors that
     333# should be viewed/fixed, and 0 otherwise.
     334# ----------------------------------------------------------------------
     335proc main_errors {args} {
    333336    global ErrList ErrListPos
     337
     338    set strict no
     339    while {[llength $args] > 0} {
     340        set flag [lindex $args 0]
     341        set args [lrange $args 1 end]
     342        if {$flag eq "-strict"} {
     343            set strict yes
     344        } else {
     345            error "bad option \"$flag\": should be -strict"
     346        }
     347    }
    334348
    335349    set ErrList ""
     
    443457                set errors "these errors"
    444458            } else {
    445                 set errors "at least the $nerrs errors"
     459                set errors "at least the $nerrs error"
     460                if {$nerrs > 1} {lappend errors "s"}
    446461            }
    447462        }
     
    449464        # if there are errors, we can't continue on
    450465        if {$nerrs > 0} {
    451             tk_messageBox -icon error -type ok -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  You must resolve $errors before you continue with the preview."
    452             return 1
     466            if {$strict} {
     467                tk_messageBox -icon error -type ok -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  You must resolve $errors before you continue with the preview."
     468                return 1
     469            } else {
     470                set resp [tk_messageBox -icon error -type yesno -title "Rappture: Problems with your tool definition" -message "$thereis $phrases for your current tool definition.  Examine and resolve $problem?"]
     471                return $resp
     472            }
    453473        }
    454474
     
    649669            $win.scrl.skel select none
    650670
    651             # generate now to catch any errors
    652             main_generate_xml
     671            # freshen up the ToolXml
     672            if {![main_generate_xml]} {
     673                # something went wrong while saving the xml
     674                # pull up the build tab, so we can see the error
     675                .func select "Build"
     676                return
     677            }
     678
     679            if {[main_errors]} {
     680                .func select "Build"
     681                pack .func.build.options.errs \
     682                    -before .func.build.options.panes \
     683                    -pady {10 0} -fill x
     684                main_errors_nav 0
     685                return
     686            }
    653687
    654688            # get the language choice and update the skeleton program option
     
    750784                main_generate_xml
    751785
     786                # change any !Language for the command into a proper
     787                # invocation command.  Grab the XML before we do this
     788                # as the last official XML that's been saved.  We'll
     789                # know later if things changed and we need to save again.
     790                set xmlBeforeCmdSubst [$ToolXml xml]
     791
    752792                set cmd [$ToolXml get tool.command]
    753793                if {[string index $cmd 0] eq "!"} {
     
    773813                    set status "error"
    774814                } else {
    775                     set LastToolXmlLoaded [$ToolXml xml]
     815                    set LastToolXmlLoaded $xmlBeforeCmdSubst
    776816                }
    777817            }
     
    932972
    933973    if {[$ToolXml xml] ne $LastToolXmlLoaded} {
    934         set choice [tk_messageBox -icon warning -type yesno -title "Rappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"]
     974        set choice [tk_messageBox -icon warning -type yesnocancel -title "Rappture: Save Changes?" -message "Changes to the current tool haven't been saved.\n\nSave changes?"]
    935975        if {$choice == "yes" && ![main_saveas]} {
     976            return
     977        } elseif {$choice == "cancel"} {
    936978            return
    937979        }
  • branches/blt4/builder/scripts/templates/python.tl

    r2170 r2294  
    7979    code "\n# save output value for $path"
    8080    code "# this shows just one (x,y) point -- modify as needed"
    81     code "line = "%g %g\n" % (x, y)"
     81    code "line = \"%g %g\n\" % (x, y)"
    8282    code "io.put('$path.component.xy', line, append=1)"
    8383  }
     
    8686    code "# this shows just one point -- modify as needed"
    8787    code "# (x,h,w) = x-coord, height of bar, and width of bar (optional)"
    88     code "line = "%g %g %g\n" % (x, h, w)"
     88    code "line = \"%g %g %g\n\" % (x, h, w)"
    8989    code "io.put('$path.component.xhw', line, append=1)"
    9090  }
Note: See TracChangeset for help on using the changeset viewer.