163 lines
		
	
	
	
		
			5.1 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			163 lines
		
	
	
	
		
			5.1 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
# ----------------------------------------------------------------------
 | 
						|
#  DEMO: mainwindow in [incr Widgets]
 | 
						|
# ----------------------------------------------------------------------
 | 
						|
package require Iwidgets 4.0
 | 
						|
 | 
						|
wm withdraw .
 | 
						|
iwidgets::mainwindow .mw
 | 
						|
 | 
						|
set imagedir [file join ${iwidgets::library} demos images]
 | 
						|
 | 
						|
#
 | 
						|
# Add a File menubutton
 | 
						|
#
 | 
						|
.mw menubar add menubutton file -text "File" -underline 0 -padx 8 -pady 2 \
 | 
						|
    -menu {options -tearoff no
 | 
						|
	   command new -label "New" -underline 0 \
 | 
						|
	       -helpstr "Create a new file"
 | 
						|
	   command open -label "Open ..." -underline 0 \
 | 
						|
	       -helpstr "Open an existing file"
 | 
						|
	   command save -label "Save" -underline 0 \
 | 
						|
	       -helpstr "Save the current file"
 | 
						|
	   command saveas -label "Save As ..." -underline 5 \
 | 
						|
	       -helpstr "Save the file as a differnet name"
 | 
						|
	   command print -label "Print" -underline 0 \
 | 
						|
	       -helpstr "Print the file"
 | 
						|
           separator sep1
 | 
						|
	   command close -label "Close" -underline 0 \
 | 
						|
	       -helpstr "Close the file"
 | 
						|
	   separator sep2
 | 
						|
	   command exit -label "Exit" -underline 1 \
 | 
						|
	       -helpstr "Exit this application" 
 | 
						|
    }
 | 
						|
 | 
						|
#
 | 
						|
# Add the Edit menubutton.
 | 
						|
#
 | 
						|
.mw menubar add menubutton edit -text "Edit" -underline 0 -padx 8 -pady 2 \
 | 
						|
    -menu {options -tearoff no
 | 
						|
	   command cut -label "Cut" -underline 2 \
 | 
						|
	       -helpstr "Cut the selection into the clipboard"
 | 
						|
           command copy -label "Copy" -underline 0 \
 | 
						|
	       -helpstr "Copy the selection to the clipboard"
 | 
						|
           command paste -label "Paste" -underline 0 \
 | 
						|
	       -helpstr "Paste the clipboard to the current point"
 | 
						|
           separator sep3
 | 
						|
           command find -label "Find" -underline 2 \
 | 
						|
	       -helpstr "Search the text"
 | 
						|
           separator sep4
 | 
						|
           command clear -label "Clear" -underline 2 \
 | 
						|
	       -helpstr "Clear the selection"
 | 
						|
    }
 | 
						|
 | 
						|
#
 | 
						|
# Add the Help menubutton.
 | 
						|
#
 | 
						|
.mw menubar add menubutton help -text "Help" -underline 0 -padx 8 -pady 2 \
 | 
						|
    -menu {options -tearoff no
 | 
						|
	   command onwindow -label "On Window" -underline 3 \
 | 
						|
	       -helpstr "Obtain help on the window"
 | 
						|
           command onkeys -label "On Keys" -underline 3 \
 | 
						|
	       -helpstr "Obtain help on the keys"
 | 
						|
           command index -label "Index" -underline 0 \
 | 
						|
	       -helpstr "View the help index"
 | 
						|
           command onhelp -label "On Help" -underline 2 \
 | 
						|
	       -helpstr "Obtain help on help"
 | 
						|
           command onversion -label "On Version" -underline 2 \
 | 
						|
	       -helpstr "View the version information"
 | 
						|
    }
 | 
						|
 | 
						|
#
 | 
						|
# Add items to the toolbar.
 | 
						|
#
 | 
						|
.mw toolbar add frame filler1 -width 108 -relief raised -borderwidth 2
 | 
						|
 | 
						|
.mw toolbar add button new \
 | 
						|
    -image [image create photo -file [file join $imagedir new.gif]] \
 | 
						|
    -helpstr "Create a new file" \
 | 
						|
    -balloonstr "New"
 | 
						|
 | 
						|
.mw toolbar add button open \
 | 
						|
    -image [image create photo -file [file join $imagedir open.gif]] \
 | 
						|
    -helpstr "Open an existing file" \
 | 
						|
    -balloonstr "Open"
 | 
						|
 | 
						|
.mw toolbar add button close \
 | 
						|
    -image [image create photo -file [file join $imagedir close.gif]] \
 | 
						|
    -helpstr "Close the file" \
 | 
						|
    -balloonstr "Close"
 | 
						|
 | 
						|
.mw toolbar add frame filler2 -width 20 -relief raised -borderwidth 2
 | 
						|
 | 
						|
.mw toolbar add button cut \
 | 
						|
    -image [image create photo -file [file join $imagedir cut.gif]] \
 | 
						|
    -helpstr "Cut the selection into the cut buffer" \
 | 
						|
    -balloonstr "Cut"
 | 
						|
 | 
						|
.mw toolbar add button copy \
 | 
						|
    -image [image create photo -file [file join $imagedir copy.gif]] \
 | 
						|
    -helpstr "Copy the selection to the cut buffer" \
 | 
						|
    -balloonstr "Copy"
 | 
						|
 | 
						|
.mw toolbar add button paste \
 | 
						|
    -image [image create photo -file [file join $imagedir paste.gif]] \
 | 
						|
    -helpstr "Paste the cut buffer to the current point" \
 | 
						|
    -balloonstr "Paste"
 | 
						|
 | 
						|
.mw toolbar add button clear \
 | 
						|
    -image [image create photo -file [file join $imagedir clear.gif]] \
 | 
						|
    -helpstr "Clear the selection" \
 | 
						|
    -balloonstr "Clear"
 | 
						|
 | 
						|
.mw toolbar add frame filler3 -relief raised -borderwidth 2
 | 
						|
 | 
						|
#
 | 
						|
# Add items to the menubar.
 | 
						|
#
 | 
						|
.mw mousebar add button save \
 | 
						|
    -image [image create photo -file [file join $imagedir save.gif]] \
 | 
						|
    -helpstr "Save the current file"
 | 
						|
 | 
						|
.mw mousebar add button print \
 | 
						|
    -image [image create photo -file [file join $imagedir print.gif]] \
 | 
						|
    -helpstr "Print the file"
 | 
						|
 | 
						|
.mw mousebar add button find \
 | 
						|
    -image [image create photo -file [file join $imagedir find.gif]] \
 | 
						|
    -helpstr "Search the text"
 | 
						|
 | 
						|
.mw mousebar add frame filler1 -height 20 -relief raised -borderwidth 2
 | 
						|
 | 
						|
.mw mousebar add button help \
 | 
						|
    -image [image create photo -file [file join $imagedir help.gif]] \
 | 
						|
    -helpstr "Obtain help for this window"
 | 
						|
 | 
						|
.mw mousebar add frame filler2 -relief raised -borderwidth 2
 | 
						|
 | 
						|
.mw mousebar add button exit \
 | 
						|
    -image [image create photo -file [file join $imagedir exit.gif]] \
 | 
						|
    -helpstr "Exit this application"
 | 
						|
 | 
						|
.mw mousebar add frame filler3 -height 5
 | 
						|
 | 
						|
#
 | 
						|
# Change the packing of the last fillers in the tool and mouse bar
 | 
						|
# so that it expands across and down the rest of the mainwindow.
 | 
						|
#
 | 
						|
pack [.mw toolbar component filler3] -expand yes -fill both
 | 
						|
pack [.mw mousebar component filler2] -expand yes -fill both
 | 
						|
 | 
						|
 | 
						|
#
 | 
						|
# Install a scrolledtext widget in the childsite.
 | 
						|
#
 | 
						|
iwidgets::scrolledtext [.mw childsite].st -visibleitems 40x8
 | 
						|
pack [.mw childsite].st -fill both -expand yes
 | 
						|
 | 
						|
#
 | 
						|
# Activate the main window.
 | 
						|
#
 | 
						|
.mw activate
 | 
						|
 | 
						|
 | 
						|
 |