Posted to tcl by de at Wed Jun 15 23:36:04 GMT 2011view pretty

package require Tk
package require snit
package require BWidget 

namespace eval ::wtk { }

rename button ::wtk::button

snit::widgetadaptor button {
    constructor {args} {
        installhull using ::wtk::button
        $self configurelist $args
    }
    delegate method * to hull
    delegate option * to hull
}

proc cancelCmd {} {
    puts "You hit cancel"
}

proc useProgressDlg {} {
    global nrOfDone

    set nrOfDone 0
    ProgressDlg .progressbar \
        -maximum 100 \
        -variable nrOfDone \
        -textvariable nrOfDone \
        -stop Cancel \
        -command cancelCmd
    for {set nrOfDone 0} {$nrOfDone <= 100} {incr nrOfDone} {
        after 10
        update idletasks
    }

    destroy .progressbar
    .b configure -text "Click again"
}

button .b -text "Click button" -command useProgressDlg

pack .b