<!DOCTYPE html>
<html lang="es" dir="ltr">
<head>
<base href="../../../../../">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Servicio SFWidgets.Menu</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="es/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="es/bookmarks.js" defer></script><script type="text/javascript" src="es/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="es/text/shared/05/new_help.html"><div></div></a><a class="logo" href="es/text/shared/05/new_help.html"><p dir="auto">Ayuda de LibreOffice 25.2</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Módulo</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contenido</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Buscar en los marcadores del módulo elegido" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<noscript><div id="WarnJS"><h1 dir="auto">Active JavaScript en el navegador para mostrar las páginas de ayuda de LibreOffice.</h1></div></noscript>
<a id="ScriptForge-sf_pmenu"></a>
<a id="bm_id501600788076877"></a>
<meta itemprop="keywords" content="Menu service">
<a id="abstract"></a>
<h1 id="bm_id681600788076499" dir="auto">
<a id="MenuService"></a><span class="literal">SFWidgets</span>.<span class="literal">Menu</span> service</h1>
<p id="par_id181600788076612" class="paragraph" dir="auto">The <span class="literal">Menu</span> service can be used to create and remove menus from the menubar of a LibreOffice document window. Each menu entry can be associated with a script or with a UNO command. This service provides the following capabilities:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id301600788076785" class="listitem" dir="auto">Creation of menus with custom entries, checkboxes, radio buttons and separators.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id1001600788076848" class="listitem" dir="auto">Decoration of menu items with icons and tooltips.</p>
</li>
</ul>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id581643133675012" dir="auto">Menus created with this service are available only for a specified document window. They are not saved into the document or as application settings. Closing and opening the document will restore the default menubar settings.</p></div>
</div>
<br>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id291643224925643" dir="auto">When OLE objects such as Math formulas or Calc charts are edited from within a document, LibreOffice reconfigures the menubar according to the object. When this happens, the menus created with the <span class="literal">Menu</span> service are removed and are not be restored after editing the OLE object.</p></div>
</div>
<br>
<h2 id="hd_id281600788076359" dir="auto">Invocación del servicio</h2>
<p id="par_id141609955500101" class="paragraph" dir="auto">Antes de utilizar el servicio <span class="literal">Menu</span>, es necesario cargar o importar la biblioteca <span class="literal">ScriptForge</span>:</p>
<div class="embedded">
<a id="importLibs"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id901528999850603" dir="auto">• Para cargar la biblioteca <span class="literal">ScriptForge</span> que necesitan las macros de Basic se debe usar la siguiente declaración:<br><span class="literal">GlobalScope.BasicLibraries.loadLibrary("ScriptForge")</span><br><br>• Los scripts de Python necesitan importar el módulo <span class="literal">scriptforge</span>:<br><span class="literal">from scriptforge import CreateScriptService</span></p></div>
</div>
<br>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<p id="par_id321614902851541" class="paragraph" dir="auto">The <span class="literal">Menu</span> service is instantiated by calling the <a target="_top" href="es/text/sbasic/shared/03/sf_document.html#CreateMenu"><span class="literal">CreateMenu</span></a> method from the <span class="literal">Document</span> service. The code snippet below creates a menu named <span class="emph">My Menu</span> in the current document window with two entries <span class="emph">Item A</span> and <span class="emph">Item B</span>.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub CreateMenu()
GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
Dim oDoc as Object, oMenu as Object
Set oDoc = CreateScriptService("Document")
Set oMenu = oDoc.CreateMenu("My Menu")
With oMenu
.AddItem("Item A", Command := "About")
.AddItem("Item B", Script := "vnd.sun.star.script:Standard.Module1.ItemB_Listener?language=Basic&location=application")
.Dispose()
End With
End Sub
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id371643135157996" dir="auto">After creating the menu, it is recommended to call the <span class="literal">Dispose</span> method to free the resources used by the <span class="literal">Menu</span> service instance.</p></div>
</div>
<br>
<p id="par_id341636718182262" class="paragraph" dir="auto">In the example above, <span class="emph">Item A</span> is associated with the UNO command <span class="literal">.uno:About</span> whereas <span class="emph">Item B</span> is associated with the script <span class="literal">ItemB_Listener</span> defined in <span class="literal">Module1</span> of the <span class="literal">Standard</span> library of the <span class="literal">My Macros</span> container.</p>
<p id="par_id851635274721129" class="paragraph" dir="auto">The following example defines <span class="literal">ItemB_Listener</span> that will be called when <span class="emph">Item B</span> is clicked. This listener simply splits the argument string passed to the <span class="literal">Sub</span> and shows them in a message box.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub ItemB_Listener(args As String)
' Process the argument string passed to the listener
Dim sArgs as Object
sArgs = Split(args, ",")
MsgBox "Menu name: " & sArgs(0) & Chr(13) & _
"Menu item: " & sArgs(1) & Chr(13) & _
"Item ID: " & sArgs(2) & Chr(13) & _
"Item status: " & sArgs(3)
End Sub
</code></pre></div>
<p id="par_id531636493797707" class="paragraph" dir="auto">As shown in the example above, menu entries associated with a script receive a comma-separated string argument with the following values:</p>
<ul itemprop="Unordered" itemscope="true" itemtype="http://schema.org/ItemList" dir="auto">
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id921643136489994" class="listitem" dir="auto">The toplevel name of the menu.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id611643136491059" class="listitem" dir="auto">The string ID of the selected menu entry.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id961643136491491" class="listitem" dir="auto">The numeric ID of the selected menu entry.</p>
</li>
<li itemprop="itemListElement" itemscope="true" itemtype="http://schema.org/ItemListUnordered" dir="auto">
<p id="par_id381643136494580" class="listitem" dir="auto">The current state of the menu item. This is useful for checkboxes and radio buttons. If the item is checked, the value "1" is returned, otherwise "0" is returned.</p>
</li>
</ul>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<p id="par_id131635275172617" class="paragraph" dir="auto">Los ejemplos anteriores pueden escribirse en Python de esta manera:</p>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
from scriptforge import CreateScriptService
def create_menu(args=None):
oDoc = CreateScriptService("Document")
oMenu = oDoc.CreateMenu("My Menu")
oMenu.AddItem("Item A", command="About")
oMenu.AddItem("Item B", script="vnd.sun.star.script:my_macros.py$item_b_listener?language=Python&location=user")
oMenu.Dispose()
</code></pre></div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
def item_b_listener(args):
bas = CreateScriptService("Basic")
s_args = args.split(",")
msg = f"Nombre de menú: {s_args[0]}\n"
msg += f"Elemento de menú: {s_args[1]}\n"
msg += f"Item ID: {s_args[2]}\n"
msg += f"Item status: {s_args[3]}"
bas.MsgBox(msg)
</code></pre></div>
<a id="bm_id111614901520029"></a>
<meta itemprop="keywords" content="PopupService service,ShortcutCharacter">
<meta itemprop="keywords" content="PopupService service,SubmenuCharacter">
<h2 id="hd_id711600788076834" dir="auto">Propiedades</h2>
<a id="properties_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id461600788076917" class="tableheadintable" dir="auto">Nombre</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id221600788076591" class="tableheadintable" dir="auto">De solo lectura</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id761600788076328" class="tableheadintable" dir="auto">Tipo</p>
</th>
<th rowspan="" colspan="" class="tableheadcell" dir="auto">
<p id="par_id67160078807636" class="tableheadintable" dir="auto">Descripción</p>
</th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id941600788076595" class="tablecontentintable" dir="auto">ShortcutCharacter</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id49160078807654" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id961600788076376" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id81600788076419" class="tablecontentintable" dir="auto">El carácter utilizado para definir la tecla de acceso de un elemento del menú. El predeterminado es «~».</p>
</td>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id491600788076621" class="tablecontentintable" dir="auto">SubmenuCharacter</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id311600788076756" class="tablecontentintable" dir="auto">No</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id831600788076785" class="tablecontentintable" dir="auto">String</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id441600788076826" class="tablecontentintable" dir="auto">Character or string that defines how menu items are nested. The default character is ">".</p>
</td>
</tr>
</table>
<br>
<h2 id="hd_id181636719707892" dir="auto">Menús y submenús</h2>
<p id="par_id741636719725402" class="paragraph" dir="auto">To create a menu with submenus, use the character defined in the <span class="literal">SubmenuCharacter</span> property while creating the menu entry to define where it will be placed. For instance, consider the following menu/submenu hierarchy.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
' Item A
' Item B > Item B.1
' Item B.2
' ------ (line separator)
' Item C > Item C.1 > Item C.1.1
' Item C.1.2
' Item C > Item C.2 > Item C.2.1
' Item C.2.2
' ------ (line separator)
' Item C.2.3
' Item C.2.4
</code></pre></div>
<p id="par_id211636720111489" class="paragraph" dir="auto">The code below uses the default submenu character ">" to create the menu/submenu hierarchy defined above:</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
oMenu.AddItem("Item A")
oMenu.AddItem("Item B>Item B.1")
oMenu.AddItem("Item B>Item B.2")
oMenu.AddItem("---")
oMenu.AddItem("Item C>Item C.1>Item C.1.1")
oMenu.AddItem("Item C>Item C.1>Item C.1.2")
oMenu.AddItem("Item C>Item C.2>Item C.2.1")
oMenu.AddItem("Item C>Item C.2>Item C.2.2")
oMenu.AddItem("Item C>Item C.2>---")
oMenu.AddItem("Item C>Item C.2>Item C.2.3")
oMenu.AddItem("Item C>Item C.2>Item C.2.4")
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id121636721243578" dir="auto">La cadena <span class="literal">---</span> se utiliza para definir líneas separadoras en los menús y submenús.</p></div>
</div>
<br>
<div class="embedded">
<a id="using_icons"></a>
<h3 id="hd_id211636723438558" dir="auto">Utilizar iconos</h3>
<p id="par_id981636723485402" class="paragraph" dir="auto">Items in the menu can have icons, which are specified as arguments in the <span class="literal">AddCheckBox</span>, <span class="literal">AddItem</span> and <span class="literal">AddRadioButton</span> methods.</p>
<p id="par_id881636724112434" class="paragraph" dir="auto">Todos los iconos disponibles en LibreOffice pueden utilizarse especificando su ruta relativa a la carpeta donde se encuentran los archivos de iconos en la carpeta de instalación. Los iconos se encuentran en la siguiente carpeta:</p>
<p id="par_id991636724479899" class="paragraph" dir="auto"><span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">INSTALLDIR/share/config</span></p>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id941636724808906" dir="auto">Utilice la propiedad <span class="literal">InstallFolder</span> del servicio <span class="literal">FileSystem</span> para determinar dónde está instalado LibreOffice en su sistema.</p></div>
</div>
<br>
<p id="par_id201636724575911" class="paragraph" dir="auto">This folder contains a series of ZIP files containing the image files of each available icon set. The images inside these ZIP files are organized into folders. To use an icon, specify the icon file with the path to its location inside the ZIP file.</p>
<p id="par_id641636724972071" class="paragraph" dir="auto">The example below uses the icon "sc_newdoc.svg" that is located inside the "cmd" folder. The forward slash "/" character is used as the path separator regardless of the operating system.</p>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
myMenu.AddItem("Item A", Icon := "cmd/sc_newdoc.svg")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
myMenu.AddItem("Item A", icon="cmd/sc_newdoc.svg")
</code></pre></div>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id691636725233961" dir="auto">Todos los conjuntos de iconos tienen la misma estructura interna. El icono mostrado depende del conjunto de iconos en uso actualmente.</p></div>
</div>
<br>
</div>
<h2 id="hd_id501582887473754" dir="auto">Métodos</h2>
<a id="methods_toc"></a>
<table border="1" class="" cellpadding="0" cellspacing="0">
<tr>
<th rowspan="" colspan="3" class="tableheadcell" dir="auto"><p id="par_id891611613601554" class="tableheadintable" dir="auto">Lista de métodos en el servicio Menu</p></th>
</tr>
<tr>
<td rowspan="" colspan="" dir="auto">
<p id="par_id891611613601556" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_menu.html#AddCheckBox">AddCheckBox</a><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id541611613601554" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_menu.html#AddItem">AddItem</a><br>
</p>
</td>
<td rowspan="" colspan="" dir="auto">
<p id="par_id541611613625804" class="tablecontentintable" dir="auto">
<a target="_top" href="es/text/sbasic/shared/03/sf_menu.html#AddRadioButton">AddRadioButton</a><br>
</p>
</td>
</tr>
</table>
<br>
<a id="AddCheckBox"></a>
<a id="bm_id92158919969883"></a>
<meta itemprop="keywords" content="Menu service,AddCheckBox">
<h2 id="hd_id201589199698251" dir="auto">AddCheckBox</h2>
<p id="par_id93158919969864" class="paragraph" dir="auto">Inserts a check box in the menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id821621534014732" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.AddCheckBox(menuitem: str, opt name: str, opt status: bool, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id821591631203996" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631203116" class="paragraph" dir="auto"><span class="emph">name:</span> String value used to identify the menu item. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id821591631203133" class="paragraph" dir="auto"><span class="emph">status:</span> Defines whether the item is selected when the menu is created (Default = <span class="literal">False</span>).</p>
<p id="par_id11636721653313" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653208" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<p id="par_id11636721653328" class="paragraph" dir="auto"><span class="emph">command:</span> The name of a UNO command without the <span class="literal">.uno:</span> prefix. If the command name does not exist, nothing happens.</p>
<p id="par_id11636721653107" class="paragraph" dir="auto"><span class="emph">script:</span> The URI for a Basic or Python script that will be executed when the item is clicked.</p>
<a id="menu_note"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643198954204" dir="auto">The arguments <span class="literal">command</span> and <span class="literal">script</span> are mutually exclusive, hence only one of them can be set for each menu item.</p></div>
</div>
<br>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643148484084" dir="auto">Read <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification">Scripting Framework URI Specification</a> to learn more about the URI syntax used in the <span class="literal">script</span> argument.</p></div>
</div>
<br>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
' Menu entry associated with the .uno:Paste command
oMenu.AddCheckBox("Item A", Status := True, ToolTip := "Paste values", Command := "Paste")
' Runs the Basic script Standard.Module1.MyListener stored in the document
oMenu.AddCheckBox("Item B", Status := False, Script := "vnd.sun.star.script:Standard.Module1.MyListener?language=Basic&location=document")
' Runs the Python script MyListener located in file myScripts.py in the user scripts folder
oMenu.AddCheckBox("Item C", Status := True, Script := "vnd.sun.star.script:myScripts.py$MyListener?language=Python&location=user")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
oMenu.AddCheckBox("Item A", status=True, tooltip="Paste values", command="Paste")
oMenu.AddCheckBox("Item B", status=False, script="vnd.sun.star.script:Standard.Module1.MyListener?language=Basic&location=document")
oMenu.AddCheckBox("Item C", Status=True, Script="vnd.sun.star.script:myScripts.py$MyListener?language=Python&location=user")
</code></pre></div>
<a id="AddItem"></a>
<a id="bm_id92158919960353"></a>
<meta itemprop="keywords" content="Menu service,AddItem">
<h2 id="hd_id201589199698158" dir="auto">AddItem</h2>
<p id="par_id93158919963364" class="paragraph" dir="auto">Inserts a label entry in the menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id821621534012185" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.AddItem(menuitem: str, opt name: str, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id821591631203021" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631203026" class="paragraph" dir="auto"><span class="emph">name:</span> String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id11636721652886" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653118" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<p id="par_id11636721653314" class="paragraph" dir="auto"><span class="emph">command:</span> The name of a UNO command without the <span class="literal">.uno:</span> prefix. If the command name does not exist, nothing happens.</p>
<p id="par_id11636721652057" class="paragraph" dir="auto"><span class="emph">script:</span> The URI for a Basic or Python script that will be executed when the item is clicked.</p>
<div class="embedded">
<a id="menu_note"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643198954204" dir="auto">The arguments <span class="literal">command</span> and <span class="literal">script</span> are mutually exclusive, hence only one of them can be set for each menu item.</p></div>
</div>
<br>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643148484084" dir="auto">Read <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification">Scripting Framework URI Specification</a> to learn more about the URI syntax used in the <span class="literal">script</span> argument.</p></div>
</div>
<br>
</div>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
oMenu.AddItem("Item A", Tooltip := "A descriptive message")
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
oMenu.AddItem("Item A", tooltip = "A descriptive message")
</code></pre></div>
<a id="AddRadioButton"></a>
<a id="bm_id92158919969447"></a>
<meta itemprop="keywords" content="Menu service,AddRadioButton">
<h2 id="hd_id201589199693022" dir="auto">AddRadioButton</h2>
<p id="par_id93158919969399" class="paragraph" dir="auto">Inserts a radio button entry in the menu. Returns an integer value that identifies the inserted item.</p>
<div class="embedded">
<a id="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Sintaxis:</h3>
</div>
<p id="par_id821621534013775" class="paragraph" dir="auto">
<span class="input" data-tooltip="Pulse en el texto para copiarlo en el portapapeles">svc.AddRadioButton(menuitem: str, opt name: str, opt status: str, opt icon: str, opt tooltip: str, opt command: str, opt script: str): int</span>
</p>
<div class="embedded">
<a id="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parámetros:</h3>
</div>
<p id="par_id821591631203501" class="paragraph" dir="auto"><span class="emph">menuitem:</span> Defines the text to be displayed in the menu. This argument also defines the hierarchy of the item inside the menu by using the submenu character.</p>
<p id="par_id821591631228716" class="paragraph" dir="auto"><span class="emph">name:</span> String value to be returned when the item is clicked. By default, the last component of the menu hierarchy is used.</p>
<p id="par_id821591631203643" class="paragraph" dir="auto"><span class="emph">status:</span> Defines whether the item is selected when the menu is created (Default = <span class="literal">False</span>).</p>
<p id="par_id11636721653228" class="paragraph" dir="auto"><span class="emph">icon:</span> Path and name of the icon to be displayed without the leading path separator. The actual icon shown depends on the icon set being used.</p>
<p id="par_id11636721653114" class="paragraph" dir="auto"><span class="emph">tooltip:</span> Text to be displayed as tooltip.</p>
<p id="par_id11636721653447" class="paragraph" dir="auto"><span class="emph">command:</span> The name of a UNO command without the <span class="literal">.uno:</span> prefix. If the command name does not exist, nothing happens.</p>
<p id="par_id11636721652598" class="paragraph" dir="auto"><span class="emph">script:</span> The URI for a Basic or Python script that will be executed when the item is clicked.</p>
<div class="embedded">
<a id="menu_note"></a>
<div class="note">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643198954204" dir="auto">The arguments <span class="literal">command</span> and <span class="literal">script</span> are mutually exclusive, hence only one of them can be set for each menu item.</p></div>
</div>
<br>
<div class="tip">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/tip.svg" alt="tip" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id31643148484084" dir="auto">Read <a target="_blank" href="https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification">Scripting Framework URI Specification</a> to learn more about the URI syntax used in the <span class="literal">script</span> argument.</p></div>
</div>
<br>
</div>
<div class="embedded">
<a id="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Ejemplo:</h3>
</div>
<div class="embedded">
<a id="In_Basic"></a>
<h5 id="hd_id191620312698501" dir="auto">En BASIC</h5>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-visual-basic line-numbers">
oMenu.AddRadioButton("Item A", Name := "A", Status := True)
</code></pre></div>
<div class="embedded">
<a id="In_Python"></a>
<h5 id="hd_id831620312769993" dir="auto">En Python</h5>
</div>
<div class="pycode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Pulse en el texto para copiarlo en el portapapeles"><pre dir="auto"><code class="language-python line-numbers">
oMenu.AddRadioButton("Item A", name="A", status=True)
</code></pre></div>
<div class="embedded">
<a id="SF_InternalUse"></a>
<div class="warning">
<div class="noteicon" dir="auto"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" style="width:40px;height:40px;"></div>
<div class="notetext"><p id="par_id851506659675843" dir="auto">Todas las rutinas o identificadores BASIC de <span class="literal">ScriptForge</span> precedidas por guion bajo «_» están reservadas para uso interno. No deben utilizarse en macros BASIC o secuencias Python.</p></div>
</div>
<br>
</div>
<a id="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a id="related"></a><span class="emph">Temas relacionados</span></p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_popupmenu.html"><span class="literal">SFWidgets</span>.<span class="literal">PopupMenu</span> service</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="es/text/sbasic/shared/03/sf_document.html">Servicio <span class="literal">SFDocuments</span>.<span class="literal">Document</span></a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><h2 style="text-align: center;"><a href="https://books.libreoffice.org" target="_blank">Libros de LibreOffice</a></h2>
<div class="noteicon" dir="auto" style="display:flex;justify-content:center;flex-wrap:wrap;row-gap:15px;">
<img src="media/navigation/libo-writer.svg" alt="Writer Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-calc.svg" alt="Calc Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-impress.svg" alt="Impress Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-draw.svg" alt="Draw Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-base.svg" alt="Base Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-math.svg" alt="Math Icon" style="width:60px;height:60px;"><img src="media/navigation/libo-symbol-black.svg" alt="Getting Started Icon" style="width:60px;height:60px;">
</div>
<div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03/sf_menu.xhp" target="_blank">/text/sbasic/shared/03/sf_menu.xhp</a></p>
<p dir="auto">Title is: Servicio SFWidgets.Menu</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>