Posted to tcl by patthoyts at Tue Oct 02 23:43:24 GMT 2007view raw

  1. # Demo spare window in the taskbar when using embedded safetk in a toplevel
  2. # The Main function is ok, only one taskbar entry created, but when we launch the
  3. # Dialog function we get a new black - we shouldn't because the dialog is
  4. # transient.
  5.  
  6. proc Dialog {} {
  7. set dlg [toplevel .dlg -container 1]
  8. wm transient $dlg .
  9. wm title $dlg "SafeTk in dialog"
  10. safe::interpCreate dialog
  11. safe::loadTk dialog -use $dlg
  12. interp eval dialog {. configure -background red}
  13. bind $dlg <Destroy> [list interp delete dialog]
  14. .l configure -text "container: [winfo id $dlg]\
  15. slave: [interp eval dialog {winfo id .}]"
  16. }
  17.  
  18. proc Main {} {
  19. wm title . "Embed test"
  20. frame .f -container 1
  21. label .l -text "" -anchor nw
  22. button .b -text Exit -command {set ::forever 1}
  23. button .b1 -text Dialog -command {Dialog}
  24. safe::interpCreate slave
  25. safe::loadTk slave -use .f
  26. slave eval {. configure -background blue}
  27. grid .f - -sticky news
  28. grid .l - -sticky news
  29. grid .b1 .b -sticky e
  30. grid rowconfigure . 0 -weight 1
  31. grid columnconfigure . 0 -weight 1
  32. bind . <Control-F2> {console show}
  33. tkwait variable ::forever
  34. }
  35.  
  36. if {!$tcl_interactive} {
  37. set r [catch [linsert $argv 0 Main] err]
  38. if {$r} {tk_messageBox -icon error -message $::errorInfo}
  39. exit $r
  40. }