Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
set folderIcon [image create photo -file D:/TclTest/folder.gif]
.mbar.file add command -image $folderIcon
menu .mbar
. configure -menu .mbar
set folderIcon [image create photo -file D:/TclTest/folder.gif]
.mbar add cascade -image $folderIcon -menu .mbar.special
menu .mbar.special -tearoff 0
# First create a frame for the menubar
# and pack it at the top of the window.
frame .mbar
pack .mbar -side top -anchor w
# Now let's create some placeholder contents
# for the window.
pack [text .t] -expand yes -fill both
# Create our image object. Here's where you'll
# have to supply your own image file.
set folderIcon [image create photo -file D:/TclTest/folder.gif]
# Create a menubutton to put in the menubar,
# and have it display the image object we
# just created.
# By the way, I find that giving the menubuttons
# an internal -pady of 2 is more visually
# pleasing and closer to the appearance of
# the standard menubars.
menubutton .mbar.folder -image $folderIcon -menu .mbar.folder.menu -pady 2
# Hook it up to a menu with a couple of
# dummy entries.
menu .mbar.folder.menu -tearoff 0
.mbar.folder.menu add command -label "Open" -command {puts "Open"}
.mbar.folder.menu add command -label "Close" -command {puts "Close"}
# Create another menu just to show what it
# will look like.
menubutton .mbar.view -text "View" -underline 0 -pady 2 -menu .mbar.view.menu
menu .mbar.view.menu
.mbar.view.menu add command -label "Zoom In" -underline 5 -command {puts "Zoom In"}
.mbar.view.menu add command -label "Zoom Out" -underline 5 -command {puts "Zoom Out"}
# Pack the menubuttons into the "menubar"
# frame.
pack .mbar.folder .mbar.view -side left
# The Alt key accelerators don't seem to
# work by default on menubuttons. So, let's
# create our own procedure to post a
# menubutton's popup menu properly.
proc postMenu {menu} {
set x [winfo rootx $menu]
set y [expr {[winfo height $menu] + [winfo rooty $menu]} ]
$menu.menu post $x $y
}
# Now actually create the bindings to post
# the menus.
bind . <Alt-KeyPress-f> {
postMenu .mbar.folder
}
bind . <Alt-KeyPress-v> {
postMenu .mbar.view
}