A menubutton widget displays a textual label and/or image, and displays a menu when pressed.

tic_menubutton(..., text, bind = NULL, pack = NULL)

Arguments

...

Other arguments are parsed as follows:

named arguments

Further options to be used during the creation of this widget. See the tcl/tk documentation for all arguments possible for this widget.

unnamed arguments

Container widgets (e.g. tic_frame()) treat any unnamed arguments as child objects. Non-container widgets (e.g tic_button()) will raise an error if there are any unnamed widgets.

text

Specifies a text string to be displayed inside the widget.

text

Simple character string containing the name

textvariable

Reactive variable containing a string

bind

bind commands to particular events on this element. This may be a single result of bind_opts() or a list of them for multiple events.

pack

how this object should be packed into its parent. pack has no effect for tic_menu() or tic_menu_item().

Value

handle on the tcl/tk object

Details

Include items in this menu using tic_menuitem() and tic_submenu()

tcl/tk

See tcl/tk documentation for more information on this element https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_menubutton.htm

Examples

tic_menubutton(
  text = "Press for menu",
  tic_menuitem("Run a command", menutype = "command", command = function() {
    message("This is where a command is run")
  }),
  tic_submenu(
    label = "Sub menu here",
    tic_menuitem("Run this", "command", command = function() { message("Hello")})
  )
)
#> List of 5
#>  $ args    :List of 1
#>   ..$ text: chr "Press for menu"
#>  $ type    : chr "menubutton"
#>  $ children:List of 2
#>   ..$ :List of 6
#>   .. ..$ args    :List of 3
#>   .. .. ..$ label     : chr "Run a command"
#>   .. .. ..$ command   :function ()  
#>   .. .. .. ..- attr(*, "srcref")= 'srcref' int [1:8] 3 65 5 3 65 3 3 5
#>   .. .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x7f996be66710> 
#>   .. .. ..$ background: chr "white"
#>   .. ..$ type    : chr "menuitem"
#>   .. ..$ menutype: chr "command"
#>   .. ..$ children: list()
#>   .. ..$ binding : NULL
#>   .. ..$ pack    : NULL
#>   ..$ :List of 6
#>   .. ..$ args    :List of 2
#>   .. .. ..$ tearoff   : logi FALSE
#>   .. .. ..$ background: chr "white"
#>   .. ..$ type    : chr "submenu"
#>   .. ..$ children:List of 1
#>   .. .. ..$ :List of 6
#>   .. .. .. ..$ args    :List of 3
#>   .. .. .. .. ..$ label     : chr "Run this"
#>   .. .. .. .. ..$ command   :function ()  
#>   .. .. .. .. .. ..- attr(*, "srcref")= 'srcref' int [1:8] 8 51 8 80 51 80 8 8
#>   .. .. .. .. .. .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' <environment: 0x7f996be66710> 
#>   .. .. .. .. ..$ background: chr "white"
#>   .. .. .. ..$ type    : chr "menuitem"
#>   .. .. .. ..$ menutype: chr "command"
#>   .. .. .. ..$ children: list()
#>   .. .. .. ..$ binding : NULL
#>   .. .. .. ..$ pack    : NULL
#>   .. ..$ binding : NULL
#>   .. ..$ label   : chr "Sub menu here"
#>   .. ..$ pack    : NULL
#>  $ binding : NULL
#>  $ pack    : NULL