rp.menu(rpanel)
rp.menu()所属R语言包:rpanel
Top level menu for a panel
顶级菜单面板
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function adds a menu to the top of the panel window. When a menu item is selected, a variable is set and an action function is called.
此功能面板窗口的顶部添加了一个菜单。当一个菜单项被选中时,变量被设置,一个动作函数被调用。
用法----------Usage----------
rp.menu(panel, var, labels, initval = NULL, parent = window, action = I, ...)
参数----------Arguments----------
参数:panel
the panel to which the menu should be attached should appear. This may be passed as a panelname string or the panel object itself.
该菜单应的面板应该会出现。这可能是通过作为一个panelname的字符串或面板对象本身。
参数:var
the name of the variable whose value is set by the menu.
的名称的变量,其值被设置菜单。
参数:labels
the labels for the menu options. These values are returned through var. The menu is defined by a list of lists of character strings. Each major menu heading should be the first item in the sub-lists with the submenu items listed afterwards in the same list. Please see the example.
菜单选项的标签。这些值是通过无功返回。菜单的具体定义的列表,字符串列表。每个主菜单的标题应该是子列表中的第一项,之后在同一列表中列出的子菜单项。请看到的例子。
参数:initval
the initial value of <var> (optional). The initial value can also be specified in the call to rp.control.
的初始值<VAR>(可选)。的初始值,也可以指定在调用rp.control。
参数:parent
this specifies the widget inside which this widget should appear. In the current version, it should not normally be used.
指定小工具,里面这个小部件出现。在目前的版本中,它不应该被使用。
参数:action
the function which is called when a menu item is chosen.
选择菜单项时调用的函数。
参数:...
any further parameters.
任何进一步的参数。
Details
详细信息----------Details----------
The function action should take one argument, which should be the panel to which the listbox is attached.<br> <br> The list for a menu consisting of "File" and "Edit" only would be defined thus;<br> list(list("File"), list("Edit"))<br> <br> The list for a menu consisting of "File" with subitem "Quit" and "Edit" with subitems "Copy", "Cut" and "Paste" would be defined thus;<br> list(list("File", "Quit"), list("Edit", "Copy", "Cut", "Paste"))
的功能action一个参数,这应该是面板的列表框连接。<BR> <BR>组成的“文件”,“编辑”,不仅会被定义为一个菜单的列表; <BR>列表(列表(“文件”),表(“编辑”))的网参考<BR>的列表菜单的“文件”子项“退出”子项“复制”和“编辑”, “剪切”和“粘贴”,将被定义从而<BR>列表(列表(“文件”,“退出”),表(“编辑”,“复制”,“剪切”,“粘贴”))
值----------Value----------
If the parameter panel is the panelname string the same string is returned. If the panel object is used the altered panel is assigned to both the calling level and panel's environment level.
如果该参数面板是panelname的的字符串相同的字符串返回。如果面板对象是用来改变的面板被分配到的层次和面板的环境。
警告----------Warning----------
The action function should return the panel. Without this assignment any widgets added or alterations made to panel parameters within the action function will be lost.<br> <br> The action function must be defined before the rp.menu statement as it relies on the function already existing.
action函数应该返回面板。如果没有这个任务添加任何部件或在action功能面板参数的改变将会丢失。<BR> <BR>的操作功能,必须定义前rp.menu表,因为它依赖于现有的功能。
参考文献----------References----------
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
参见----------See Also----------
rp.checkbox,rp.control
rp.checkbox,rp.control
实例----------Examples----------
if (interactive()) {
a <- rp.control()
# The action function has to come first so that it already exists for rp.menu, [操作功能是第一位的,以便它已经存在rp.menu,]
# as it creates the callback functions on the fly it requires action to already [因为它创造了在飞行中的回调函数,它需要行动,已经]
# be defined.[被定义。]
domenu <- function(panel) {
rp.messagebox(panel$menuchoice, title = "You chose")
panel
}
rp.menu(a, menuchoice, labels=list(list("File","Quit"),
list("Edit","Copy","Cut","Paste")), action=domenu)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|