Precept 3: More about assignment 1


Lab TA hours

There'll be a lab TA in the "MECA" lab on Thursday evening in the week before an assignment is due, and on Thursday and Friday evening in the week an assignment is due.


Links

The links I talked about in precept:

Dialog box for value input

Taken from page 207 of "Practical Programming in Tcl and Tk" by Brent Welch:

proc GetValue { prompt_text } {
        global prompt
        set f [toplevel .prompt -borderwidth 10 ]
        message $f.msg -text $prompt_text -width 400
        set prompt(result) ""
        entry $f.entry -textvariable prompt(result)
        set b [frame $f.buttons -bd 10]
        pack $f.msg $f.entry $f.buttons -side top -fill x
        button $b.ok -text OK -command {set prompt(ok) 1} \
            -underline 0
        button $b.cancel -text Cancel \
            -command {set prompt(ok) 0} -underline 0
        pack $b.ok -side left
        pack $b.cancel -side right

        # setup bindings for shortcuts...
        foreach w [list $f.entry $b.ok $b.cancel] {
                bindtags $w [list .prompt [winfo class $w] $w all]
        }
        bind .prompt <Alt-o> "focus $b.ok ; break"
        bind .prompt <Alt-c> "focus $b.cancel ; break"
        bind .prompt <Alt-Key> break
        bind .prompt <Return> {set prompt(ok) 1}
        bind .prompt <Control-c> {set prompt(ok) 0}
        focus $f.entry
        grab $f
        tkwait variable prompt(ok)
        grab release $f
        destroy $f
        if {$prompt(ok)} {
                return $prompt(result)
        } else {
                return {}
        }
}

You can also copy the file (or ftp it if you're on a CS machine) from /u/rjjensen/Pub/tcltk/getvalue.tk.


Patrick Min, CS Department, Princeton University
Last modified: Wed Oct 2 23:42:20 1996