38-visicon.tcl 1.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
proc select_visicon {} {

  if {[currently_selected_model] == "nil"} {

    tk_messageBox -icon info -type ok -title "Visicon" -message "Inspector tools require a current model."
  } else {

    set win ".visicon_[currently_selected_model]"

    if {[winfo exists $win] == 1} {
      wm deiconify $win
      raise $win
    } else {
      # make it now

      toplevel $win

      wm withdraw $win

      record_new_window $win "Visicon"

      wm geometry $win [get_configuration .visicon $win]

      set f [frame $win.frame -borderwidth 0]  
    
      set t [text $f.text -font text_font -yscrollcommand "$f.scrl set" -state disabled]
          
      set s [scrollbar $f.scrl -command "$t yview"]

      send_environment_cmd \
        "create text-output-handler $t $t \
            (lambda (x) (declare (ignore x)) (print-visicon)) (post) [send_model_name]"

      bind $t <Destroy> {
        remove_handler %W
      }

      # Make the window useable for copy operations on Windows
   
      bind $t <1> {focus %W}
  
      pack $s -side right -fill y 
      pack $t -side left -expand 1 -fill both
  
      place $f -x 0 -y 0 -relwidth 1.0 -relheight 1.0 

      # now show the window 

      wm deiconify $win
    }
  }
}

button [control_panel_name].visicon_button \
       -command {select_visicon} -text "Visicon" -font button_font

pack [control_panel_name].visicon_button