In the next example we have a mainmenu with aData. How can we have a submenu with 开发者_运维问答aData1 and aData2 ?
library(gWidgets)
options(guiToolkit = "RGtk2")
aData <- gaction(label="File", icon="file")
aData1 <- gaction(label="Open", icon="open")
aData2 <- gaction(label="Close", icon="close")
ml <- list(Data=aData)
gmenu(ml, container = TRUE)
This is related to your previous question. The answer is basically no, but if you are willing to use the developmental version of gWidgets2:
require(devtools)
install_github("gWidgets2", username="jverzani")
install_github("gWidgets2RGtk2", username="jverzani")
then you can hack this in, as that version allows you to put in widgets into the toolbar. Here is something that kind of works:
w <- gwindow()
h <- function(h,...) print("hi")
l <- list(file=gaction("file", icon="ok", handler=h),
open=gaction("open", icon="open", handler=h),
quit=gaction("quit", icon="quit", handler=h))
popup <- gmenu(l, popup=TRUE)
tbl <- list(c=gaction("cancel", icon="cancel", handler=h),
b=gbutton("file")) ## adding a widget
addPopupMenu(tbl$b, popup) ## put popup menu on b
tbl$b$remove_border()
tb = gtoolbar(tbl, cont=w, style="both-horiz")
glabel("fill me in", cont=w)
I still need to add some of the widgets into this version (no tree widget, data frame editor, and others yet).
I think you're looking for this:
gmenu(menulist = list(File = list(Open = aData1, Close = aData2)), container = TRUE)
精彩评论