tk2swaplist: A list selector that allows to select and arrange items...

View source: R/tk2swaplist.R

tk2swaplistR Documentation

A list selector that allows to select and arrange items freely

Description

The swaplist is perfect to select and arrange items in a given order from a fixed initial set of possible items.

Usage

tk2swaplist(items, selection, title = "Select items", ...)

Arguments

items

A vector with all items.

selection

A vector with preselected items (must be a subset of items).

title

The title of the dialog box, by default, "Select items".

...

Further parameters passed to swaplist, see its tcl man page: https://core.tcl-lang.org/tklib/doc/trunk/embedded/www/tklib/files/modules/swaplist/swaplist.html.

Value

A vector with the selected items in the chosen order.

See Also

tk2listbox(), tk2tablelist()

Examples

## Not run: 
library(tcltk2)
# tk2swaplist() makes its use super-easy
tk2swaplist(1:9, selection = c(1, 3, 5))

# Use of the swaplist on your own
tclRequire("swaplist")
tt <- tktoplevel()
opts <- tclVar()
sl <- tcl("swaplist::swaplist", tt, opts, 1:9, c(1, 3, 5))
cat("You choose:", tclvalue(opts), "\n")
rm(opts, sl, tt)

## End(Not run)

tcltk2 documentation built on June 8, 2025, 1:04 p.m.