[R-gui] seeking R tcltk solution
John Fox
jfox at mcmaster.ca
Wed Jul 27 19:49:29 CEST 2005
Dear Bill,
Yes, it's possible to do this, but a little tricky, since you need to save
the "ID" and "position" of the menu item so that you can then address it. I
do menu activation/deactivation in the Rcmdr package using this function:
activateMenus <- function(){
for (item in getRcmdr("Menus")){
if (item$activation()) .Tcl(paste(item$ID, " entryconfigure ",
item$position - 1," -state normal", sep=""))
else .Tcl(paste(item$ID, " entryconfigure ", item$position - 1,"
-state disabled", sep=""))
}
}
What's of direct interest to you, I think, is the first call to .Tcl for
enabling a menu item (where item$ID is the item ID and item$position, which
I previously saved).
If you'd like a bit more context, see as well the function Commander() in
the file Commander.R in the source for the Rcmdr package, and in particular
near line 600.
I hope this helps,
John
--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox
--------------------------------
> -----Original Message-----
> From: r-sig-gui-bounces at stat.math.ethz.ch
> [mailto:r-sig-gui-bounces at stat.math.ethz.ch] On Behalf Of
> morphwj at comcast.net
> Sent: Wednesday, July 27, 2005 12:07 PM
> To: r-sig-gui at stat.math.ethz.ch
> Subject: [R-gui] seeking R tcltk solution
>
> The following short block of code creates a menu bar with
> menu item "graphic" disabled:
>
> TopWindow <- tktoplevel(parent=.TkRoot)
> TopMenu <- tkmenu(TopWindow)
> tkconfigure(TopWindow,menu=TopMenu)
> FileMenu <- tkmenu(TopMenu)
> GraphicsMenu <- tkmenu(TopMenu)
> tkadd(TopMenu,"cascade",label="File", menu=FileMenu)
> tkadd(TopMenu,"cascade",label="Graphics", menu=GraphicsMenu,
> state="disabled")
>
> Other than tkdestroy(TopMenu)and rebuilding the menubar
> omitting'state="disabled"', is there a way to change the
> state of the menu item "Graphics" to "normal"?
>
> Bill Morphet, Space Shuttle engineer & PhD statistics student
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-gui
More information about the R-SIG-GUI
mailing list