dropdownList: A widget to mimic a dropdown list

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/dropdownList.R

Description

The current tcltk library does not support dropdown lists unless an extension is included. The function dropdownList provide an alternative.

Usage

1
2
3
dropdownList(base, options, textvariable, width = 10, default, editable
= FALSE)
getListOption(targetWidget, options, height, vScroll = FALSE)

Arguments

base

base a tkwin object that is the parent frame of the dropdown list to be created

options

options a vector of character strings for the content of the dropdown list

textvariable

textvariable a tclVar object to be associated with the selected item of the dropdown list

width

width an integer for the width in number of characters of the selection containing part of the dropdown list

default

default a character string for the default selection that is going to be shown in the selection containing window of the dropdown list

targetWidget

targetWidget a tkwin object for an entry box to which a button will be associated to make the look of a dropdown list

editable

editable a boolean indicating whether the dropdown list will be editable or not

height

height an integer for the height of the dropdown list box. If missing, height will be assigned the length of the options to be shown in the list box

vScroll

vScroll a boolean indicating whether a vertical scroll bar will be associated with the dropdown list box

Details

base can be a top window or a frame.

The widget returns a frame that contains a dropdown list. The frame need to be placed using any of the layout methods of tcltk. The value of the selection will be accessed through the tclVar object passed to the function.

getListOptions is called by dropdown list to get the selected item

Value

dropdownList returns a tkwin object for the frame that contains a dropdown list

getListOptions returns a character string for the selected item

Author(s)

Jianhua Zhang

References

tcltk

See Also

tooltip

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
    ## These cannot be run by examples() but should be OK when pasted
    ## into an interactive R session with the widgetTools package loaded
    
    base <- tktoplevel()
    selection <- tclVar()
    dropdownList(base, c("Option 1", "Option 2", "Option 3"),
          selection, 15, "Option 2")
    tclvalue(selection)
    # Destroy toplevel widget
    # tkdestroy(base)

## End(Not run)

widgetTools documentation built on Nov. 8, 2020, 8:29 p.m.