[R] tkmenu question

Ross Darnell r.darnell at shrs.uq.edu.au
Thu Jan 30 05:08:03 CET 2003


I am learning the tcl/tk package and language and working through an
example (following a Tcl/Tk) tutorial which constructs a menubar and
menu system. My code is below.  I would very much appeciate some help
with two questions.

1. What is the parent for the menus associated with the menubuttons?

2. Why does the toplevel frame shrink if though I define the width of
the menubar frame and set the fill="x"?

Thanks

Ross Darnell


-- 
Email: <r.darnell at shrs.uq.edu.au>


require(tcltk) || stop("tcltk support is absent")
# Generate the main frame
.fr <- tktoplevel(width=800,height=500)
tktitle(.fr) <- "My example"
.menubar <- tkframe(.fr, relief="raised", borderwidth=2,
                    width=500,height=15)
tkpack(.menubar,fill="x") #why does .fr shrink?
# Set up the menu buttons
.menubar.file <- tkmenubutton(.menubar, text="File",
                              underline=0,menu=.menubar.file.menu)
.menubar.edit <- tkmenubutton(.menubar, text="Edit",
                              underline=0,menu=.menubar.edit.menu)
.menubar.graphics <- tkmenubutton(.menubar, text="Graphics",
                                  underline=0,menu=.menubar.graphics.menu)
tkpack(.menubar.file, .menubar.edit, .menubar.graphics,fill="x",
       side="left")
# Help menu to the right
.menubar.help <- tkmenubutton(.menubar, text="Help", underline=0)
tkpack(.menubar.help, side="right",fill="x")
# create pulldown menus  what is the parent?
.menubar.file.menu <- tkmenu(.)
tkadd(.menubar.file.menu,"separator")
tkadd(.menubar.file.menu,"command",label="Quit",command="exit")
.menubar.edit.menu <- tkmenu(.)
tkadd(.menubar.edit.menu,"separator")
.menubar.graphics.menu <- tkmenu(.)
tkadd(.menubar.graphics.menu,"separator")




More information about the R-help mailing list