reference/ocr-new/new_ui.tcl
changeset 0 6b8091ca909a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reference/ocr-new/new_ui.tcl	Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,1086 @@
+#
+# user interface code (tcl visuals) for OCR
+# started 9/95, Archie Russell 
+wm withdraw .
+append OCRCHIE_ROOT [pwd] "/"
+append face_image $OCRCHIE_ROOT face_happy.xbm
+append eye_image $OCRCHIE_ROOT eye.xbm
+append write_image $OCRCHIE_ROOT edit2.xbm
+
+set xvprocess "0"
+set main_window_width 800
+set main_window_height 800
+set dummy 0
+# I'd like to be able to use the above parameters in here,
+# but I think tcl might get a little angry if I try
+# the size of the window, and the position of its upper left
+set main_window_geometry 800x800+200+100
+
+set menu_bar_width $main_window_width
+set menu_bar_height 50
+set button_bar_width $main_window_width
+set button_bar_height 50
+set display_height 400
+set edit_window_height 300
+set quit_dialog_geometry 300x135+500+500
+set save_ascii_geometry 275x140+500+500
+# save a little room for scrollbars, etc.
+
+set BACKGROUND #CCCCCC
+set FOREGROUND #000000
+set SELECT white
+# set FONT -bitstream-*-medium-r-normal--26-171-110-110-p-150-iso8859-1
+#set FONT -bitstream-*-medium-r-normal--19-140-85-85-p-110-hp-roman8
+#set SMALLFONT -bitstream-*-medium-r-normal--19-140-85-85-p-110-hp-roman8
+#2 lines above changed to 2 lines below 5/17/96 RJF
+set FONT -bitstream-*-medium-r-normal-*-19-*-75-75-p-110-iso8859-1
+set SMALLFONT -bitstream-*-medium-r-normal-*-19-*-75-75-p-110-iso8859-1
+
+
+
+set EDIT_BACKGROUND #000000
+set LOW_PRECISION_BACKGROUND blue
+set MISPELLED_BACKGROUND SeaGreen
+set UNKNOWN_CHAR_BACKGROUND red
+
+set scroll_inc 30
+
+
+
+set canvas_width [expr $main_window_width - 30]
+set canvas_hight [expr $main_window_height -30]
+global variables for equation  marking
+set curx 0
+set cury 0
+set curline 0
+set curline_startrow 0
+set curline_endrow 0
+set in_equation 0
+set WbxEquationsOnly 0
+#Was the component selected valid in component_select
+set validComponent 0
+
+#comp_menu.tcl holds all of the component options, join, split, and learn
+source "comp_menu.tcl"   
+
+#multi_zone.tcl holds the code for displaying a document for zoning
+set multiZone_display_open 0
+source "multi_zone.tcl"
+
+proc init_user_interface {} {
+    
+# tcl requires declaration of global variables used in a fxn
+
+    global main_window_geometry main_window_width main_window_height menu_bar_width menu_bar_height button_bar_width button_bar_height display_height BACKGROUND FOREGROUND EDIT_BACKGROUND edit_window_height validComponent
+
+# toplevel windows are at the same level as 'xterms'    
+    toplevel .main_window
+
+# $ sign means 'get the value' (otherwise uses the string)
+    wm geometry .main_window $main_window_geometry
+    wm title .main_window "OCR user interface"
+    wm minsize . 400 300
+    .main_window configure -background $BACKGROUND
+# frames are subwindows that are there mostly to 'hold' other windows
+    frame .main_window.menu_bar -width $menu_bar_width -height $menu_bar_height -relief raised -bd 2 -background $BACKGROUND
+    init_menu_bar
+
+    frame .main_window.button_bar -width $button_bar_width -height $button_bar_height -background $BACKGROUND 
+    init_button_bar
+    
+
+    init_display
+
+    frame .main_window.edit_window -width $main_window_width -height $edit_window_height -relief ridge -bd 5 -bg $EDIT_BACKGROUND
+    init_edit_window
+
+# pack puts things together: this will put the menu_bar window just above the button_bar_window above the display
+    
+    pack .main_window.menu_bar -side top -fill x
+    pack .main_window.button_bar .main_window.display .main_window.edit_window -side top -anchor w -fill x
+    focus .main_window
+
+    bind .main_window.display <Enter> {
+	SWITCH_TO_ACTIVE_PAGE
+    }
+
+#Mark an equation 
+    bind .main_window.display.work_space <ButtonPress-3> {
+	equation_mark %W %x %y }
+#Delete an equation
+    bind .main_window.display.work_space <Double-2> {
+	equation_delete %W %x %y }
+#Bind <Control-l> to learn
+    bind .main_window.display.work_space <Control-l> {
+	set curx [%W canvasx %x] 
+	set cury [%W canvasy %y] 
+	component_select %W $curx $cury
+	component_learn
+    }
+
+ #Select a component
+   	
+    bind .main_window.display.work_space <Double-1> {
+	if { [component_select %W [%W canvasx %x] [%W canvasy %y] ] } {
+        init_component_menu %W [%W canvasx %x] [%W canvasy %y] 
+	}   
+    }
+
+}
+
+
+proc init_menu_bar { } {
+# this command initializes the main menu bar (stuff like file, etc)
+# shortcuts not working! why?
+    global BACKGROUND FOREGROUND FONT
+
+    menubutton .main_window.menu_bar.file -text "File " -menu .main_window.menu_bar.file.menu -borderwidth 2 -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+    init_file_menu
+
+    menubutton  .main_window.menu_bar.tools -text "Tools " -menu .main_window.menu_bar.tools.menu  -borderwidth 2 -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+    init_tools_menu
+
+    menubutton  .main_window.menu_bar.options -text "Options " -menu .main_window.menu_bar.options.menu  -borderwidth 2 -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+    init_options_menu
+
+    menubutton  .main_window.menu_bar.windows -text "Windows " -menu .main_window.menu_bar.windows.menu  -borderwidth 2 -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+    init_windows_menu
+
+    pack .main_window.menu_bar.file .main_window.menu_bar.tools .main_window.menu_bar.options .main_window.menu_bar.windows -side left -padx 1m -pady 1m 
+
+
+    button  .main_window.menu_bar.help -text "Help"  -borderwidth 2 -background $BACKGROUND -foreground $FOREGROUND -font $FONT -relief flat \
+	    -command { init_help .main_window.menu_bar.help }
+ 
+    pack .main_window.menu_bar.help -side right
+}
+
+
+
+
+proc init_file_menu { } {
+# this creates the menu associated with the file menubutton
+    global FOREGROUND BACKGROUND FONT
+    menu .main_window.menu_bar.file.menu -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+# and these initialize the entries in the menu (open is linked to the command popup_open_menu)
+    .main_window.menu_bar.file.menu add command -label "Open..." -command popup_open_menu 
+    .main_window.menu_bar.file.menu add command -label "Close" -command close_document 
+    .main_window.menu_bar.file.menu add separator
+#    .main_window.menu_bar.file.menu add command -label "Save TIFF" -command popup_save_tiff_menu 
+    .main_window.menu_bar.file.menu add command -label "Save ASCII" -command popup_save_ascii_menu 
+#    .main_window.menu_bar.file.menu add command -label "Save WORD/POS" -command popup_save_word_pos_menu 
+    .main_window.menu_bar.file.menu add command -label "Save WORDBOX" -command popup_save_wordbox_menu 
+    .main_window.menu_bar.file.menu add command -label "Save EQUATION BOUNDS" -command popup_save_equations_menu 
+
+    .main_window.menu_bar.file.menu add command -label "Save Learned Characters" -command popup_save_learned_chars_menu 
+    .main_window.menu_bar.file.menu add command -label "Read Learned Characters" -command popup_read_learned_chars_menu 
+
+#    .main_window.menu_bar.file.menu add command -label "Save Setup" -command popup_save_setup_menu 
+# a separator is just a horizontal line for show
+    .main_window.menu_bar.file.menu add separator
+    .main_window.menu_bar.file.menu add command -label "Quit" -command popup_quit_dialog_box 
+}
+
+proc close_document { } {
+    .main_window.edit_window.text_part delete 1.0 end
+    .main_window.display.work_space delete all
+
+    set COLORED_WORDS {}
+    if { [winfo exist .zoning_window] } {
+	focus .zoning_window
+	zone_message "No active zone"
+    } else {
+	DEALLOCATE_PAGE
+  
+    }
+}
+
+
+proc init_tools_menu { } {
+# this creates the menu associated with the tools menubutton
+    global BACKGROUND FOREGROUND FONT
+    menu .main_window.menu_bar.tools.menu -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+# and these initialize the entries in the menu (open is linked to the command popup_open_menu)
+
+#    supposed to just find the angle and tell you what it is...
+#    .main_window.menu_bar.tools.menu add command -label "Skew Angle" -command popup_skew_angle_menu 
+
+#  supposed to let the user arbitrarily rotate the image
+#    .main_window.menu_bar.tools.menu add command -label "Rotate" -command popup_rotate_menu
+
+    .main_window.menu_bar.tools.menu add command -label "Extract Components" -command EXTRACT_COMP
+    .main_window.menu_bar.tools.menu add command -label "Recognize" -command popup_recognize_menu
+    .main_window.menu_bar.tools.menu add command -label "Learn" -command popup_learn_menu
+    .main_window.menu_bar.tools.menu add separator
+    .main_window.menu_bar.tools.menu add command -label "Zoom in" -command ZOOM_IN
+    .main_window.menu_bar.tools.menu add command -label "Zoom out" -command ZOOM_OUT
+    .main_window.menu_bar.tools.menu add separator
+    .main_window.menu_bar.tools.menu add command -label "Refresh" -command DISPLAY_INTERVALS 
+    .main_window.menu_bar.tools.menu add command -label "Deskew" -command popup_deskew_menu
+
+# automated spell correction
+#    .main_window.menu_bar.tools.menu add command -label "SpellCorrect" -command popup_correct_menu
+
+# interactive learning
+#    .main_window.menu_bar.tools.menu add command -label "Learn Mode" -command popup_learn_mode
+}
+
+set CURRENT_DEFAULT_FONT Helvetica
+set CURRENT_DEFAULT_SIZE 9
+proc popup_learn_mode { } {
+    global BACKGROUND FOREGROUND SMALLFONT FONT
+    toplevel .learn 
+    frame .learn.c -width 100 -height 100
+    canvas .learn.c.c -background $BACKGROUND -width 100 -height 100
+    pack .learn.c.c
+    frame .learn.s
+    entry .learn.s.learned_string -width 5 -bg $BACKGROUND -fg $FOREGROUND -font $SMALLFONT -selectbackground $SELECT
+    .learn.s.learned_string  icursor 0
+    .learn.s.learned_string select range 0 10
+    label .learn.s.string_message -text "Ascii" -bg $BACKGROUND -fg $FOREGROUND -font $SMALLFONT
+    pack .learn.s.learned_string .learn.s.string_message -side left -expand 1 
+
+    tk_optionMenu .learn.font CURRENT_DEFAULT_FONT Helvetica Courier Times 
+    .learn.font configure -bg $BACKGROUND -fg $FOREGROUND -font $SMALLFONT
+    .learn.font.menu configure -bg $BACKGROUND -fg $FOREGROUND
+    tk_optionMenu .learn.size CURRENT_DEFAULT_SIZE 9 10 12 18 
+    .learn.size configure -bg $BACKGROUND -fg $FOREGROUND -font $SMALLFONT
+    .learn.size.menu configure -bg $BACKGROUND -fg $FOREGROUND
+    frame .learn.buttons
+    button .learn.buttons.ok -text Learn -command learn_ok -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .learn.buttons.cancel -text Skip -command learn_skip -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .learn.buttons.ok .learn.buttons.cancel -side left -expand 1 -fill x 	    
+    pack .learn.c .learn.s .learn.font .learn.size .learn.buttons -side top -fill x 
+}
+
+
+proc init_windows_menu { } {
+# this creates the menu associated with the windows menubutton.  Just 
+    #focuses the window
+
+    global FOREGROUND BACKGROUND FONT
+    menu .main_window.menu_bar.windows.menu -background $BACKGROUND -foreground $FOREGROUND -font $FONT
+# and these initialize the entries in the menu (open is linked to the command popup_open_menu)
+    .main_window.menu_bar.windows.menu add command -label "Zoning Window" -command { if { [winfo exists .zoning_window] } {focus .zoning_window} }
+    .main_window.menu_bar.windows.menu add command -label "Active Window" -command {focus .main_window}
+   
+}
+    
+proc init_help { path } {
+    global FOREGROUND BACKGROUND FONT
+
+
+    if { [winfo exists $help] } {
+	focus $help
+	return
+    }
+
+    set help [toplevel .main_help ]
+    wm title $help "Active Window Help"
+#    wm geometry $help  400x500+600+150
+    message $help.msg -background white -foreground $FOREGROUND -font $FONT\
+	    -width 600  -text "\n\
+	    Mark Equation  - <Button3> at start and end of Equation \n\
+            Delete Equation- <Double-2> within the equation \n\n\
+            Component Menu - <Double-1> within the component boundaries \n\
+            \t Join  - Select \[Join\] and <Double-1> on component to join\n\
+	    \t Split - Select \[Horizontal Split\] or \[Vertical Split\]\n\
+            \t Learn - Select \[Learn\] and enter value. \n"
+
+            
+	                 
+    pack $help.msg -fill x -fill y -expand true
+    
+}
+
+proc popup_deskew_menu { } {
+    puts stdout "Calling get_skew"
+    DESKEW 
+}
+
+proc popup_recognize_menu { } {
+    puts stdout "Calling recognize from Tcl"
+    RECOGNIZE
+}
+proc popup_learn_menu { } {
+        puts stdout "Calling interactive learn from Tcl"
+    
+    set fileid [open recog.tmp w]
+    puts $fileid [.main_window.edit_window.text_part get 1.0 end]
+    close $fileid
+  
+    # last argument synchronizes words
+    LEARN_PAGE recog.tmp 1
+    
+}
+
+set XV 2
+proc init_options_menu { } {
+    global dummy word_certainty_value screen_view_style FOREGROUND BACKGROUND FONT XV
+    menu .main_window.menu_bar.options.menu -foreground $FOREGROUND -background $BACKGROUND -font $FONT
+    .main_window.menu_bar.options.menu add command -label "Warning Levels..." -command popup_confidence_menu
+
+#    .main_window.menu_bar.options.menu add command -label "Zoom Ratio" -command popup_zoom_ratio_menu
+    .main_window.menu_bar.options.menu add checkbutton -label "Display Line Boundaries" -variable DISPLAY_LINE_BOUNDARIES
+    .main_window.menu_bar.options.menu add checkbutton -label "Display Bounding Boxes" -variable DISPLAY_BOUNDING_BOXES
+    .main_window.menu_bar.options.menu add checkbutton -label "Spellcheck" -variable SPELLCHECK
+    .main_window.menu_bar.options.menu add separator
+    .main_window.menu_bar.options.menu add radiobutton -label "No Display" -variable DISPLAY_IMAGE -value 0
+    .main_window.menu_bar.options.menu add radiobutton -label "OCRchie Display" -variable DISPLAY_IMAGE -value 1
+    .main_window.menu_bar.options.menu add radiobutton -label "xv" -variable DISPLAY_IMAGE -value $XV
+    .main_window.menu_bar.options.menu add separator
+    .main_window.menu_bar.options.menu add radiobutton -label "No deskew" -variable DESKEW_METHOD -value -1
+    .main_window.menu_bar.options.menu add radiobutton -label "RLE rotate" -variable DESKEW_METHOD -value 1
+    .main_window.menu_bar.options.menu add radiobutton -label "Bitmap rotate" -variable DESKEW_METHOD -value 0
+    .main_window.menu_bar.options.menu add cascade -label "Global Vars" \
+	    -menu .main_window.menu_bar.options.menu.globals
+    init_global_menu { NoiseTolerance MinLineSize MinVertSeparation \
+	MinHorizSeparation ConfidenceThreshold JoinTolerance }
+	    
+
+
+}
+
+set GLOBAL_MESSAGE "<none>"
+proc init_button_bar { } {
+    global FONT BACKGROUND FOREGROUND GLOBAL_MESSAGE
+    message .main_window.button_bar.msg -font $FONT -background $BACKGROUND -foreground $FOREGROUND -width 400
+    pack .main_window.button_bar.msg
+}
+
+proc init_display { } {
+    global display_height canvas_width canvas_height FOREGROUND BACKGROUND IMAGE_DISPLAY_WIN main_window_width display_height scroll_inc 
+    frame .main_window.display -width $main_window_width -height $display_height -relief ridge -bd 5 -bg $BACKGROUND
+    canvas .main_window.display.work_space -bg white -xscrollcommand ".main_window.display.xscroller set" -yscrollcommand ".main_window.display.yscroller set" -xscrollincrement $scroll_inc -cursor {crosshair black gray} -width $canvas_width -height $display_height 
+# two scrollbars
+    scrollbar .main_window.display.xscroller -command ".main_window.display.work_space xview" -orient horizontal -background $BACKGROUND
+    scrollbar .main_window.display.yscroller -command ".main_window.display.work_space yview" -background $BACKGROUND
+
+    pack .main_window.display.xscroller -side bottom -fill x
+    
+    pack  .main_window.display.yscroller -side right -fill y 
+    pack .main_window.display.work_space -side top -fill x
+    set IMAGE_DISPLAY_WIN .main_window.display.work_space
+    .main_window.display.work_space configure -scrollregion { 0 0 5000 5000 }
+   
+#    box_init
+}
+
+proc init_edit_window { } {
+    global edit_window_height canvas_width EDIT_BACKGROUND COLORED_WORDS LOW_PRECISION_BACKGROUND MISPELLED_BACKGROUND UNKNOWN_CHAR_BACKGROUND SMALLFONT SCALE_FACTOR scroll_inc
+    text .main_window.edit_window.text_part -bg $EDIT_BACKGROUND -height $edit_window_height -width $canvas_width -insertbackground yellow -insertwidth 8 -font $SMALLFONT -fg white -wrap word
+    pack .main_window.edit_window.text_part -side bottom
+    .main_window.edit_window.text_part tag configure LOW_PRECISION -background $LOW_PRECISION_BACKGROUND
+    .main_window.edit_window.text_part tag configure MISPELLED -background $MISPELLED_BACKGROUND
+    .main_window.edit_window.text_part tag configure UNKNOWN_CHAR -background $UNKNOWN_CHAR_BACKGROUND
+# Tab binding for the window is supposed to advance the cursor to the
+# next uncertain word and scroll the image display to show the image
+# of that word
+    bind .main_window.edit_window.text_part <Tab> {
+	if {[llength $COLORED_WORDS] == 0} {
+	    puts stdout "No more words"
+	} else {
+	    .main_window.edit_window.text_part mark set insert [pop_colored_words]
+	    set xpos [pop_colored_words]
+	    set ypos [pop_colored_words]
+#	    puts "xpos and ypos for this word"
+	    set ulx [expr $SCALE_FACTOR * ($xpos - 300)]
+	    set uly [expr $SCALE_FACTOR * ($ypos - 100)]
+	    set lrx [expr $SCALE_FACTOR * ($xpos + 300)]
+	    set lry [expr $SCALE_FACTOR * ($ypos + 100)]
+# I could never get this scrolling to work quite right, maybe
+# someone will figure it out someday 	    
+	    .main_window.display.work_space configure -scrollregion [list $ulx $uly $lrx $lry]
+	    .main_window.display.work_space configure -scrollregion {0 0 5000 5000}
+#	    .main_window.display.work_space xview moveto [expr (($SCALE_FACTOR * $xpos) / $scroll_inc)]
+#	    .main_window.display.work_space yview moveto [expr (($SCALE_FACTOR * $ypos) / $scroll_inc)]
+	    
+	    set x [.main_window.edit_window.text_part index insert]
+#	    puts "New index is $x"
+	    .main_window.edit_window.text_part see insert
+	    set local_tags [.main_window.edit_window.text_part tag names insert]
+#	    puts "Tags at this place: $local_tags"
+	}
+	break
+    }
+}
+
+proc addword { w {xpos 0} {ypos 0} {status OK}} {
+    global COLORED_WORDS LOW_PRECISION_BACKGROUND MISPELLED_BACKGROUND UNKNOWN_CHAR_BACKGROUND
+#    puts stdout "Adding $w with status $status"
+
+    if { ![string compare $status OK] } {
+	.main_window.edit_window.text_part insert end "$w " 
+	.main_window.edit_window.text_part mark set insert end
+    } elseif { ![string compare $status LOW_PRECISION] || ![string compare $status MISPELLED] || ![string compare $status UNKNOWN_CHAR] } {
+	.main_window.edit_window.text_part insert end "$w" $status
+	.main_window.edit_window.text_part insert end " "
+#       xpos and ypos can be tags too, but they really slow things down
+#	.main_window.edit_window.text_part mark set insert end
+#	.main_window.edit_window.text_part mark set insert "end -3 char"
+#	.main_window.edit_window.text_part tag add $status "insert wordstart" "insert wordend"
+#	.main_window.edit_window.text_part tag add x$xpos "insert wordstart" "insert wordend"
+#	.main_window.edit_window.text_part tag add y$ypos "insert wordstart" "insert wordend"
+	.main_window.edit_window.text_part mark set insert "end -3 char"
+	.main_window.edit_window.text_part mark set insert "insert wordstart"
+	lappend COLORED_WORDS [.main_window.edit_window.text_part index insert]
+	lappend COLORED_WORDS $xpos
+	lappend COLORED_WORDS $ypos
+	.main_window.edit_window.text_part mark set insert end
+    } else {
+	puts stdout "Unknown word status for $w: $status"
+	.main_window.edit_window.text_part insert end "$w UNKNOWNSTATUS? "
+    }
+}
+
+proc pop_colored_words { } {
+    global COLORED_WORDS
+    set x [lindex $COLORED_WORDS 0]
+    if {[llength $COLORED_WORDS] == 1} {
+	set COLORED_WORDS {}
+    } elseif {[llength $COLORED_WORDS] == 0} {
+	set COLORED_WORDS $COLORED_WORDS
+    } else {
+	set COLORED_WORDS [lrange $COLORED_WORDS 1 [llength $COLORED_WORDS]]
+    }
+    return $x
+}
+
+
+set open_menu_geometry 250x300+400+400
+set current_directory [pwd]
+set box_entry $current_directory
+set open_menu_pattern *.tif
+
+set singleZone "Single Zone"
+set multiZone "Multi Zone"
+set zoning "Single Zone"
+
+proc popup_open_menu { } {
+#
+# this procedure pops up an interactive box which can be used to open files
+# what a horrible mess.  Writing it took forever
+#
+    global open_menu_geometry open_menu_pattern current_directory FONT FOREGROUND BACKGROUND SMALLFONT box_entry singleZone multiZone zoning SELECT
+    
+    if { [winfo exists .open_menu] } {
+	focus .open_menu
+	return
+    }
+    toplevel .open_menu
+    wm geometry .open_menu $open_menu_geometry
+    wm title .open_menu Open
+    .open_menu configure -background $BACKGROUND
+    # force the user to interact with this box
+    # grab set .open_menu 
+
+    # directory listing and scrollbar
+    frame .open_menu.dirstuff
+
+    frame .open_menu.cur_dir
+    label .open_menu.cur_dir.l -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -text "Dir: "
+    entry .open_menu.cur_dir.e -relief sunken -bd 2 -textvariable box_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT -selectbackground $SELECT
+    .open_menu.cur_dir.e  icursor 0
+
+
+    frame .open_menu.zone  
+
+    radiobutton .open_menu.zone.single -variable zoning -value $singleZone \
+    -text $singleZone -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT 
+
+    radiobutton .open_menu.zone.multi -variable zoning -value $multiZone \
+    -text $multiZone -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT 
+
+    pack .open_menu.zone.single -side left
+    pack .open_menu.zone.multi -side left
+    pack .open_menu.zone -side top -fill x
+
+    .open_menu.cur_dir.e icursor end
+    bind .open_menu.cur_dir.e <Return> {
+	set file_to_open $box_entry
+	if [file isdirectory $file_to_open] {
+	    cd $file_to_open
+	    set current_directory [pwd]
+	    clear_directory_box
+	    puts stdout "Changing to  $current_directory"
+	    fill_in_directory_box $current_directory $open_menu_pattern
+	} elseif [file exists $file_to_open] {
+	    puts stdout "Opening file $file_to_open"
+	    if { $zoning == $singleZone } {
+		singleZone_open $file_to_open
+	    } else
+		{ multiZone_open $file_to_open }
+	    destroy .open_menu
+	} else {
+	    puts stdout "Cannot acccess that file"
+	}
+    }
+    pack .open_menu.cur_dir.l .open_menu.cur_dir.e -side left
+
+    scrollbar .open_menu.dirstuff.yscroll -command ".open_menu.dirstuff.directory yview" -background $BACKGROUND
+    listbox .open_menu.dirstuff.directory -yscrollcommand ".open_menu.dirstuff.yscroll set" -width 22 -height 11 -relief raised -font $SMALLFONT -background $BACKGROUND -foreground $FOREGROUND
+
+    fill_in_directory_box $current_directory $open_menu_pattern
+    bind .open_menu.dirstuff.directory <Double-Button-1> {
+	set file_to_open [selection get]
+#        puts stdout "Bound button"	
+	if [file isdirectory $file_to_open] {
+	    cd $file_to_open
+	    set current_directory [pwd]
+	    clear_directory_box
+#	    puts stdout "Changing to  $current_directory"
+	    fill_in_directory_box $current_directory $open_menu_pattern
+	} elseif [file exists $file_to_open] {
+#	    puts stdout "Opening file $file_to_open"
+	    if { $zoning == $singleZone } {
+		singleZone_open $file_to_open
+	    } else { multiZone_open $file_to_open }
+	    destroy .open_menu.dirstuff.directory
+	    destroy .open_menu
+	} else {
+	    puts stdout "Cannot access that file"
+	}
+    }
+    # pattern for listings to match
+
+
+    frame .open_menu.pattern_match -background $BACKGROUND 
+    label .open_menu.pattern_match.label -text "Match files of type:" -font $SMALLFONT -background $BACKGROUND -fg $FOREGROUND
+    entry .open_menu.pattern_match.entry -width 5 -relief sunken -bd 2 -textvariable open_menu_pattern -font $SMALLFONT -background $BACKGROUND -fg $FOREGROUND
+    # refresh the directory listing after user presses return
+    bind .open_menu.pattern_match.entry <Return> {
+	set current_directory [pwd]
+	clear_directory_box
+	fill_in_directory_box $current_directory $open_menu_pattern
+    }
+    
+    pack .open_menu.pattern_match.label .open_menu.pattern_match.entry -side left
+    pack .open_menu.dirstuff.directory .open_menu.dirstuff.yscroll -side left -fill y 
+
+    
+    pack .open_menu.pattern_match .open_menu.cur_dir .open_menu.dirstuff -side top -anchor w
+    focus .open_menu.pattern_match.entry
+}
+
+
+proc popup_confidence_menu { } {
+# a little box for the user to change the confidence 
+# warning levels (words that get highlighted)
+    global BACKGROUND FOREGROUND SMALLFONT FONT
+    toplevel .confidence -background $BACKGROUND
+    wm geometry .confidence 250x225+500+500
+    message .confidence.m -text "Warning thresholds for the output display\n (255 = warn unless perfect)" -background $BACKGROUND -foreground $FOREGROUND -font $SMALLFONT -justify center -width 250
+    scale .confidence.very_low -from 0 -to 255 -variable VERY_LOW_CONFIDENCE -orient horizontal -label "Poor (displayed in red)" -background $BACKGROUND -foreground $FOREGROUND -font $SMALLFONT
+    scale .confidence.low -from 0 -to 255 -variable LOW_CONFIDENCE -orient horizontal -label "Fair (displayed in blue)" -background $BACKGROUND -foreground $FOREGROUND -font $SMALLFONT
+    pack .confidence.m .confidence.very_low .confidence.low -side top -fill x
+}
+
+proc singleZone_open { filename } {
+# 1 means success
+    global IMAGE_DISPLAY_WIN SCALE_FACTOR DISPLAY_IMAGE XV xvprocess
+#   puts stdout "Opening $filename"
+    page_open $filename
+#   puts stdout "Done putting into page structure"
+    if { 1 }  {
+	set display_height [expr $SCALE_FACTOR * [get_page_height]]
+	set display_width [expr $SCALE_FACTOR * [get_page_width]]
+	append geometry [expr int($display_width)] x [expr int($display_height)]
+#	puts stdout "Displaying Image"
+	if { $DISPLAY_IMAGE == $XV } {
+	    set xvprocess [exec xv $filename &]
+	    puts stdout "xvprocess $xvprocess"
+	} else {
+# use the canvas...
+	DISPLAY_INTERVALS .main_window.display.work_space $SCALE_FACTOR
+	FIND_LINES
+	}
+    } else {
+	popup_image_failure_win
+    }
+    puts stdout "Determining Line boundaries"
+
+}
+
+set save_entry "recog.txt"
+proc popup_save_ascii_menu { } {
+#
+#  Pops up a little window for saving the ascii recognized text
+#  Should have a general function for all the saves, but now
+#  they are just cuts and pastes
+#
+#
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry OCRCHIE_ROOT write_image SELECT
+    
+    set save_entry recog.txt
+    toplevel .save_ascii -background $BACKGROUND
+    wm geometry .save_ascii $save_ascii_geometry
+    wm title .save_ascii "Save ASCII Text"
+    grab set .save_ascii
+    
+
+    label .save_ascii.image -bitmap @$write_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .save_ascii.s -background $BACKGROUND
+    label .save_ascii.s.txt -text "Save ascii text as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .save_ascii.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT -selectbackground $SELECT
+  
+    .save_ascii.s.ent icursor 0
+    .save_ascii.s.ent select range  0 12
+    
+    pack .save_ascii.s.txt .save_ascii.s.ent -side top
+    frame .save_ascii.buttons
+    button .save_ascii.buttons.ok -text OK -command save_ascii -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .save_ascii.buttons.cancel -text Cancel -command save_ascii_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .save_ascii.buttons.ok .save_ascii.buttons.cancel -side left -expand 1 -fill x 	
+    pack .save_ascii.image .save_ascii.s .save_ascii.buttons -side top
+
+    bind .save_ascii.s.ent <Return> {
+	save_ascii
+    }
+}
+
+proc save_ascii_cancel { } {
+    destroy .save_ascii
+}
+    
+proc save_ascii { } {
+    # need to put some error checking in here
+    global save_entry
+    set fileid [open $save_entry w]
+    puts $fileid [.main_window.edit_window.text_part get 1.0 end]
+    close $fileid
+    destroy .save_ascii
+}
+
+proc popup_save_word_pos_menu { } {
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry OCRCHIE_ROOT face_image
+
+    set save_entry recog.wps
+    toplevel .save_word_pos -background $BACKGROUND
+    wm geometry .save_word_pos $save_ascii_geometry
+    wm title .save_word_pos "Save in word/pos format"
+    grab set .save_word_pos
+
+    label .save_word_pos.image -bitmap @$face_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .save_word_pos.s -background $BACKGROUND
+    label .save_word_pos.s.txt -text "Save word_pos text as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .save_word_pos.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    pack .save_word_pos.s.txt .save_word_pos.s.ent -side top
+    frame .save_word_pos.buttons
+    button .save_word_pos.buttons.ok -text OK -command save_word_pos -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .save_word_pos.buttons.cancel -text Cancel -command save_word_pos_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .save_word_pos.buttons.ok .save_word_pos.buttons.cancel -side left -expand 1 -fill x 	
+    pack .save_word_pos.image .save_word_pos.s .save_word_pos.buttons -side top
+
+    bind .save_word_pos.s.ent <Return> {
+	save_word_pos
+    }
+}
+
+proc save_word_pos_cancel { } {
+    destroy .save_word_pos
+}
+    
+proc save_word_pos { } {
+    # need to put some error checking in here
+    global save_entry
+    WRITE_WORD_POS $save_entry
+    destroy .save_word_pos
+}
+
+proc popup_save_wordbox_menu { } {
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry OCRCHIE_ROOT face_image 	WbxEquationsOnly
+
+    set save_entry recog.wbx
+    toplevel .save_wordbox -background $BACKGROUND
+    wm geometry .save_wordbox 275x200+500+500
+    wm title .save_wordbox "Save in word/pos format"
+    grab set .save_wordbox
+
+    label .save_wordbox.image -bitmap @$face_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .save_wordbox.s -background $BACKGROUND
+    label .save_wordbox.s.txt -text "Save wordbox text as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .save_wordbox.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    pack .save_wordbox.s.txt .save_wordbox.s.ent -side top
+    frame .save_wordbox.buttons
+    checkbutton .save_wordbox.buttons.eqn \
+	    -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT \
+	    -text "Equations only" -variable WbxEquationsOnly
+    
+    button .save_wordbox.buttons.ok -text OK -command save_wordbox -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .save_wordbox.buttons.cancel -text Cancel -command save_wordbox_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .save_wordbox.buttons.eqn -side top -expand 1 -fill x
+    pack .save_wordbox.buttons.ok .save_wordbox.buttons.cancel -side left \
+	    -expand 1 -fill x 	
+
+    pack .save_wordbox.image .save_wordbox.s .save_wordbox.buttons -side top
+   
+    bind .save_wordbox.s.ent <Return> {
+	save_wordbox 
+    }
+}
+
+proc save_wordbox_cancel { } {
+    destroy .save_wordbox
+}
+    
+proc save_wordbox { } {
+    # need to put some error checking in here
+    global save_entry cur_xoffset cur_yoffset WbxEquationsOnly
+
+    WRITE_WORDBOX $save_entry $cur_xoffset $cur_yoffset $WbxEquationsOnly
+    destroy .save_wordbox
+}
+
+proc popup_save_equations_menu { } {
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry OCRCHIE_ROOT face_image cur_xoffset cur_yoffset
+
+    set save_entry recog.eqn
+    toplevel .save_equations -background $BACKGROUND
+    wm geometry .save_equations $save_ascii_geometry
+    wm title .save_equations "Save Equation boundaries"
+    grab set .save_equations
+
+    label .save_equations.image -bitmap @$face_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .save_equations.s -background $BACKGROUND
+    label .save_equations.s.txt -text "Save equation boundaries as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .save_equations.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    pack .save_equations.s.txt .save_equations.s.ent -side top
+    frame .save_equations.buttons
+    button .save_equations.buttons.ok -text OK -command save_equations -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .save_equations.buttons.cancel -text Cancel -command save_equations_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .save_equations.buttons.ok .save_equations.buttons.cancel -side left -expand 1 -fill x 	
+    pack .save_equations.image .save_equations.s .save_equations.buttons -side top
+
+    bind .save_equations.s.ent <Return> {
+	save_equations cur_xoffset cur_yoffset
+    }
+}
+
+proc save_equations_cancel { } {
+    destroy .save_equations
+}
+    
+proc save_equations { } {
+    # need to put some error checking in here
+    global save_entry
+    # second parameter is line number offset
+    WRITE_EQUATIONS $save_entry 0
+    destroy .save_equations
+}
+
+
+proc popup_save_learned_chars_menu { } {
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry face_image
+    set save_entry learn.dat
+    toplevel .save_learned_chars -background $BACKGROUND
+    wm geometry .save_learned_chars $save_ascii_geometry
+    wm title .save_learned_chars "Write Learned Characters"
+    grab set .save_learned_chars
+    
+    label .save_learned_chars.image -bitmap @$face_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .save_learned_chars.s -background $BACKGROUND
+    label .save_learned_chars.s.txt -text "Save learned characters as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .save_learned_chars.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    pack .save_learned_chars.s.txt .save_learned_chars.s.ent -side top
+    frame .save_learned_chars.buttons
+    button .save_learned_chars.buttons.ok -text OK -command save_learned_chars -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .save_learned_chars.buttons.cancel -text Cancel -command save_learned_chars_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .save_learned_chars.buttons.ok .save_learned_chars.buttons.cancel -side left -expand 1 -fill x 	
+    pack .save_learned_chars.image .save_learned_chars.s .save_learned_chars.buttons -side top
+
+    bind .save_learned_chars.s.ent <Return> {
+	save_learned_chars
+    }
+}
+
+proc save_learned_chars_cancel { } {
+    destroy .save_learned_chars
+}
+    
+proc save_learned_chars { } {
+    # need to put some error checking in here?
+    global save_entry
+    WRITE_LEARNED_CHARS $save_entry
+    destroy .save_learned_chars
+}
+
+proc popup_read_learned_chars_menu { } {
+    global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT save_entry eye_image
+    set save_entry learn.dat
+    toplevel .read_learned_chars -background $BACKGROUND
+    wm geometry .read_learned_chars $save_ascii_geometry
+    wm title .read_learned_chars "Read Learned Characters"
+    grab set .read_learned_chars
+    
+    label .read_learned_chars.image -bitmap @$eye_image -foreground $FOREGROUND -background $BACKGROUND
+    frame .read_learned_chars.s -background $BACKGROUND
+    label .read_learned_chars.s.txt -text "Read learned characters from:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    entry .read_learned_chars.s.ent -relief sunken -bd 2 -textvariable save_entry -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
+    pack .read_learned_chars.s.txt .read_learned_chars.s.ent -side top
+    frame .read_learned_chars.buttons
+    button .read_learned_chars.buttons.ok -text OK -command read_learned_chars -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    button .read_learned_chars.buttons.cancel -text Cancel -command read_learned_chars_cancel -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+    pack .read_learned_chars.buttons.ok .read_learned_chars.buttons.cancel -side left -expand 1 -fill x 	
+    pack .read_learned_chars.image .read_learned_chars.s .read_learned_chars.buttons -side top
+
+    bind .read_learned_chars.s.ent <Return> {
+	read_learned_chars
+    }
+}
+
+proc read_learned_chars_cancel { } {
+    destroy .read_learned_chars
+}
+    
+proc read_learned_chars { } {
+    # need to put some error checking in here
+    global save_entry
+    LEARN_DATA $save_entry
+    destroy .read_learned_chars
+}
+
+
+proc PAGE_OPEN { filename } {
+# unused
+    return 1
+}
+
+proc clear_directory_box { } {
+    	.open_menu.dirstuff.directory delete 0 end
+}
+
+proc fill_in_directory_box { dirname {pattern *} } {
+# fills in the directory box with directories or files matching the pattern
+    foreach i [exec ls -aF $dirname] {
+	if [file isdirectory $i] {
+	    .open_menu.dirstuff.directory insert end $i
+	} elseif [string match $pattern $i] {
+	    .open_menu.dirstuff.directory insert end $i
+	}
+    }
+}
+
+
+proc popup_quit_dialog_box { } {
+    global quit_dialog_geometry BACKGROUND FOREGROUND FONT OCRCHIE_ROOT
+
+    toplevel .quit_dialog
+    wm geometry .quit_dialog $quit_dialog_geometry
+    wm title .quit_dialog Quit
+    grab set .quit_dialog
+
+    append caution_image_name $OCRCHIE_ROOT caution.xbm
+    label .quit_dialog.image -bitmap @$caution_image_name -foreground $FOREGROUND -background $BACKGROUND
+   message .quit_dialog.msg -text "You are about to quit OCRchie.  All changes you have made will be lost." -font $FONT -background $BACKGROUND -fg $FOREGROUND -width 275 -justify center
+    frame .quit_dialog.buttons
+    button .quit_dialog.buttons.ok -text OK -command quit_ok -fg $FOREGROUND -background $BACKGROUND -font $FONT -width 5
+    button .quit_dialog.buttons.cancel -text Cancel -command quit_cancel -fg $FOREGROUND -background $BACKGROUND -font $FONT -width 5
+    pack .quit_dialog.buttons.ok .quit_dialog.buttons.cancel -side left -expand 1 -fill x 	
+    pack .quit_dialog.image .quit_dialog.msg .quit_dialog.buttons -side top -fill x
+    
+
+}
+
+proc quit_ok { } {
+#    destroy .t
+#    destroy .histogram
+    destroy .main_window
+    destroy .quit_dialog
+    QUIT
+}
+
+proc quit_cancel { } {
+    global command_not_in_progress
+    set command_not_in_progress 1
+    destroy .quit_dialog
+}
+
+proc clear_canvas { } {
+    destroy .main_window.display.work_space
+    destroy .main_window.display.xscroller
+    destroy .main_window.display.yscroller
+    destroy .main_window.display
+    init_display
+}
+
+proc spellcheck { word } {
+# spellchecks a word
+# could change to use spell or some faster program
+    global x
+    set x [exec echo $word | ispell -a]
+    if { ([string last * $x] == -1) && ([string last + $x] == -1) } {
+	return MISPELLED
+    } else {
+	return SPELLED_CORRECTLY
+    }
+}
+
+
+#Not used right now
+proc box_begin { w x y } {
+    global box
+    set box(anchor) [list $x $y]
+    catch {unset box(last)}
+}
+
+proc box_drag { w x y } {
+    global box
+    catch { $w delete $box(last) }
+    set box(last) [eval {$w create rect -fill yellow} $box(anchor) {$x $y -tag box} ]
+}
+
+
+    
+proc equation_mark { w x y } {
+    global curline curline_startrow curline_endrow curline_startcol \
+	    curline_endcol curx cury in_equation 
+    global prevline prevline_startrow prevline_endrow prevx prevy
+
+    # have to adjust x and y for scrolling canvas
+    set thisx [.main_window.display.work_space canvasx $x] 
+    set thisy [.main_window.display.work_space canvasy $y]
+
+    # save the last mark
+    set prevline $curline
+    set prevline_startrow  $curline_startrow
+    set prevline_endrow  $curline_endrow
+    set prevx $curx
+    set prevy $cury
+
+    #set curline and prevline variables by calling Page::get_linenum
+
+    GET_LINENUM $thisx $thisy
+
+     set curx $thisx
+     set cury $thisy
+
+    if { $in_equation == 0 } {
+	set in_equation 1
+	puts stdout "$curx $cury $curline $curline_startrow $curline_endrow"
+	puts stdout "$curx $cury $prevline $prevline_startrow $prevline_endrow"
+
+    } else {
+	set in_equation 0
+	puts stdout "$curx $cury $curline $curline_startrow $curline_endrow"
+	puts stdout "$curx $cury $prevline $prevline_startrow $prevline_endrow"
+	if { $curline == $prevline } {
+	    .main_window.display.work_space create rectangle $prevx  \
+		    $prevline_startrow $curx $curline_endrow  -fill yellow \
+		    -outline black -stipple @grey.25 -tags IMAGE_TAG
+	} else {
+     # polygon is 8 points (9 to connect) which surrounds the equation	
+        .main_window.display.work_space create polygon  \
+	        $prevx $prevline_startrow \
+		$curline_endcol $prevline_startrow\
+		$curline_endcol $curline_startrow \
+		$curx $curline_startrow \
+		$curx $curline_endrow \
+		$curline_startcol $curline_endrow \
+		$curline_startcol $prevline_endrow \
+		$prevx $prevline_endrow \
+		$prevx $prevline_startrow \
+		-fill yellow -outline black -stipple @grey.25 -tags IMAGE_TAG
+	}
+      # argv[1]  starting line of equation, [2] startcol [3] endline [4] endcol
+	ADD_EQUATION $prevline $prevx $curline $curx
+
+    }
+
+}
+
+    
+proc equation_delete { w x y } {
+    global curline curline_startrow curline_endrow curline_startcol \
+	    curline_endcol curx cury in_equation 
+    global prevline prevline_startrow prevline_endrow prevx prevy
+    global deleted
+    set deleted 0
+    # have to adjust x and y for scrolling canvas
+    set thisx [.main_window.display.work_space canvasx $x] 
+    set thisy [.main_window.display.work_space canvasy $y]
+
+    #deletes equation and sets prevline and curline vars for deletion
+    #also sets deleted var to 1 if equation was deleted 0 otherwise.
+
+    DELETE_EQUATION $thisx $thisy
+
+     
+
+	puts stdout "$curx $cury $curline $curline_startrow $curline_endrow"
+	puts stdout "$curx $cury $prevline $prevline_startrow $prevline_endrow"
+    if { $deleted == 0 } { return 0 }
+	if { $curline == $prevline } {
+	    .main_window.display.work_space create rectangle $prevx  \
+		    $prevline_startrow $curx $curline_endrow  -fill white \
+		    -outline white -stipple @grey.25 -tags IMAGE_TAG
+	} else {
+     # polygon is 8 points (9 to connect) which surrounds the equation	
+        .main_window.display.work_space create polygon  \
+	        $prevx $prevline_startrow \
+		$curline_endcol $prevline_startrow\
+		$curline_endcol $curline_startrow \
+		$curx $curline_startrow \
+		$curx $curline_endrow \
+		$curline_startcol $curline_endrow \
+		$curline_startcol $prevline_endrow \
+		$prevx $prevline_endrow \
+		$prevx $prevline_startrow \
+		-fill white -outline white -stipple @grey.25 -tags IMAGE_TAG
+	}
+    }
+
+
+    
+proc component_select { w x y } {
+   global curCompId validComponent
+
+   set thisx [.main_window.display.work_space canvasx $x] 
+   set thisy [.main_window.display.work_space canvasy $y]
+   SELECT_COMP $thisx $thisy
+    return $validComponent ;#Set in SELECT_COMP
+
+}
+
+proc init_global_menu { lst } {
+    global FOREGROUND BACKGROUND FONT
+    puts stdout "Entering init_global_menu \n"
+    
+    set gm [menu .main_window.menu_bar.options.menu.globals] 
+    puts stdout "This is our frame  " 
+    puts stdout $gm
+    foreach var $lst {
+	set varWindow  [string tolower $var]
+	frame $gm.$varWindow 
+	label $gm.$varWindow.l -text $var -width 20 -fg $FOREGROUND -background $BACKGROUND -font $FONT
+	entry $gm.$varWindow.set -width 4 -relief sunken -textvariable $var -fg $FOREGROUND -background $BACKGROUND -font $FONT
+	pack $gm.$varWindow.l -side left 
+ 	pack $gm.$varWindow.set -side right 
+	pack $gm.$varWindow  -side top
+    }
+
+}
+
+
+init_user_interface
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+