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

  1.  
  2. package require Tk
  3. package require snit
  4. package require BWidget
  5.  
  6. namespace eval ::wtk { }
  7.  
  8. rename button ::wtk::button
  9.  
  10. snit::widgetadaptor button {
  11. constructor {args} {
  12. installhull using ::wtk::button
  13. $self configurelist $args
  14. }
  15. delegate method * to hull
  16. delegate option * to hull
  17. }
  18.  
  19. proc cancelCmd {} {
  20. puts "You hit cancel"
  21. }
  22.  
  23. proc useProgressDlg {} {
  24. global nrOfDone
  25.  
  26. set nrOfDone 0
  27. ProgressDlg .progressbar \
  28. -maximum 100 \
  29. -variable nrOfDone \
  30. -textvariable nrOfDone \
  31. -stop Cancel \
  32. -command cancelCmd
  33. for {set nrOfDone 0} {$nrOfDone <= 100} {incr nrOfDone} {
  34. after 10
  35. update idletasks
  36. }
  37.  
  38. destroy .progressbar
  39. .b configure -text "Click again"
  40. }
  41.  
  42. button .b -text "Click button" -command useProgressDlg
  43.  
  44. pack .b
  45.