|
Mainwindow
The mainwindow iwidget can be used as an interface to an application (i.e. text or drawing editor). It includes some of the most popular widgets that are found on most application interfaces. The iwidget comes with the following widgets: menubar, toolbar, mousebar (vertical toolbar), messagedialog, 2 labels, and a childsite. The chidlsite allows the programmer to customize the interface to their specific needs; such as adding a scrolledtext or a scrolledcanvas. The following public methods are used to allow the programmer to manipulate the interface: menubar, mousebar, msgd, and toolbar. The programmer can use these public methods to manipulate each of the components. However, the programmer will need to know how each of the components work in order to manipulate them affectively.
For further information, see the Mainwindow
manpage
Components: help hull menubar mousebar msgd status toolbar
|
wm title . "Menubar Example"
##
## This is the image directory in the demos directory
##
set imagedir [file join ${iwidgets::library} demos images]
##=========================================================
## Create a mainwindow iwidget
##=========================================================
##
iwidgets::mainwindow .mw \
-title "Mainwindow Example" \
-helpline 1 \
-statusline 1
##
## Add some menu items via the menubar
## public method
##
foreach m {file edit view} {
.mw menubar add menubutton $m \
-text [string totitle $m] \
-underline 0
}
##
## Add some toolbar items via the
## toolbar public method
##
foreach t {open close clear copy cut paste} {
.mw toolbar add button $t \
-balloonstr "This is the balloon string for [string totitle $t]" \
-image [image create photo -file [file join $imagedir $t.gif]] \
-command [list puts "$t selected"] \
-helpstr "This is the help string for [string totitle $t]"
}
##
## Add some mousebar items via the
## mousebar public method
##
foreach m {save find print help exit} {
.mw mousebar add button $m \
-balloonstr "This is the balloon string for [string totitle $m]" \
-image [image create photo -file [file join $imagedir $m.gif]] \
-command [list puts "$m selected"] \
-helpstr "This is the help string for [string totitle $m]"
}
##
## Create a scrolledtext iwidget to place in
## the childsite
##
set cs [.mw childsite]
iwidgets::scrolledtext $cs.st
$cs.st import [file join / usr local tcl8.3.3 README]
pack $cs.st \
-fill both \
-expand true
update idletasks
.mw activate
|
Download this sample code |
|