• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    R
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Easily create UIs in base R

tickle

R-CMD-check

{tickle} is a package for creating UIs in base R.

This is an opinionated abstraction over the base R package {tcltk}.

This package aims to provide:

  • a simplified UI creation process similar to shiny.
  • a modern-looking visual default.
  • more documentation to help create common UI elements without resorting to the online tcl/tk documentation.
  • a way to still access the low-level tcl/tk structures in order to achieve complex effects and customisation.

What’s in the box

  • An array of tic_*() functions for nested creation of a UI specification.
  • render_ui() to render a UI specification into a window onscreen.
  • reactive_*() to create reactive values used to transfer values between the UI and R
  • canvas_*() functions to do some simple drawing an manipulation on canvas widgets.

Overview

  • Create reactive variables (with reactive_*()) in order to pass values between R and the UI. e.g.Β the value of the slider, or the text in a text entry box.
  • Define callback functions that are called, say, when a button is pressed.
  • Create a UI specification by nesting containers and widgets with tic_*() calls. This specification can include
    • binding callback functions to particular events like mouse buttons or key presses (bind argument)
    • controlling how widgets are packed within their parent container (pack argument)
  • Render the UI to an actual object on the screen with render_ui()
  • The object returned by render_ui() can be ignored by beginners. For intermediate/advanced users, this object is a nested list of tclObj objects representing the UI components, and these can be further manipulated with {tcltk} to finesse and configure the UI.

Installation

You can install from GitHub with:

# install.package('remotes')
remotes::install_github('coolbutuseless/tickle')

Hello World

Things to note:

  • Define a reactive variable for the slider before defining the UI
  • UI specificaiton created with nested tic_*() calls.
  • Some commands (e.g.Β tic_button()) have an explicit command function which is run when they are activated.
  • After defining the UI specificaiton, it is rendered to screen with render_ui()
library(tickle)

happiness <- reactive_dbl(40)

ui_spec <- tic_window(
  title = "Hello World", 
  tic_row(
    tic_col(
      tic_button("Hello", command = function() {message("Hello")}, style = 'primary'),
      tic_button("World", command = function() {message("World")})
    ),
    tic_col(
      tic_slider(happiness),
      tic_label(textvariable = happiness)
    )
  )
)

win <- render_ui(ui_spec)

Gallery

Examples/Vignettes

Please view the online vignettes for more details on how to use {tickle}

Containers

Containers are ways of grouping multiple widgets.

Containers can be nested within other containers to achieve complex layouts.

Container Code/Description
tic_window(…)
Create a top level window
tic_col(A, B, C)
Layout objects in column
tic_row(A, B, C)
Layout objects rowwise
tic_frame(…)
Invisible container. Useful for advanced users who want to customize layout
tic_labelframe(…)
Frame with a a label and usually visible outline
tic_notebook(A, B, C)
Tabbed display
tic_panedwindow(A, B, C)
Layout multiple elements which can be resized as panes

Widgets

Widget Code/Description
tic_label(…)
Display text. If you need headings rather than body text, Use style = 'h1' to style = 'h5' for different sized text
tic_button(…)
Clickable button. Available style options: β€˜primary’, β€˜seconary’, β€˜info’, β€˜success’, β€˜warning’, β€˜danger’, β€˜light’, β€˜dark’
tic_checkbutton(…)
On/off button (default styling)
tic_checkbutton(…)
On/off button with style = 'toggle'
tic_checkbutton(…)
On/off button with style = 'switch'
tic_radiobutton(…)
Groups of mutually exclusion options
tic_menubutton(…)
Button which displays a drop-down menu
tic_canvas(…)
General drawing canvas
tic_spinbox(…)
Choose options
tic_combobox(…)
Choose options
tic_textentry(…)
Single line text entry
tic_textbox(…)
Multipe line text entry
tic_progressbar(…)
Progress bar
tic_slider(…)
Slider

Popups

Popups are windows which are initiated separate from the main UI.

Popup Code/Description
popup_color_picker()
popup_messagebox()
popup_open_file()
popup_save_file()

Canvas

After creating a canvas with tic_canvas(), it can be manipulated with the following commands:

  • Draw on the canvas
    • canvas_line()
    • canvas_text()
    • canvas_rect()
    • canvas_polygon()
    • canvas_oval()
    • canvas_arc()
  • canvas_plot() render a plot to the canvas
  • canvas_clear() clear all objects from the canvas
  • canvas_image() render an image from a file to the canvas
  • canvas_save() save the contents of the canvas to an image file.

The actual canvas in tcl/tk renders structured graphics and it is much more like SVG or PDF than just a simple array of pixels.

The canvas implementation in this package treats the canvas as just a raster object i.e.Β a rectangular collection of pixels. This made it easier to write this package and keep the API/syntax simple, but it doesn’t unleash the full power of the canvas.

The effort to write a more complete abstraction over the canvas is not currently warranted. Please get in contact if such a facility is important to you.

Theme

The theme for this package is an adaptaton of the sun-valley-light theme available from rdbende on github.

The sun-valley-light theme is MIT licensed (see β€œLICENSE-sun-valley”) and has been adapted into the theme r-sun-valley-light included in this package which has the following extra features:

  • Styles β€˜h1’ through β€˜h5’ for different sized heading text to use with tic_label() widgets.
    • To use: tic_label(..., style = 'h1')
  • Standard buttons colours from Bootstrap to use with tic_button() widgets.
    • To use: tic_button(..., style = 'primary')
    • Available styles: primary, secondary, success, danger, warning, info, light, dark

Possible Future Features

The following items are not yet implemented, or incomplete:

  • Popup menus when a user right-clicks in the window.
  • No access yet to the β€œgrid” geometry layout.
  • treeview, listbox and some other widgets

Package Name

  • tcl is the scripting language
  • tk is the graphics toolkit for tcl
  • tcl/tk is often how the langauge and toolkit are talked about as a single entity
  • {tcltk} is the R package interfacing to tcl/tk
  • tcl is often pronounced as β€œtickle” i.e.Β tcl/tk = β€œtickle-tee-kay”

Acknowledgements

  • R Core for developing and maintaining the language.
  • CRAN maintainers, for patiently shepherding packages onto CRAN and maintaining the repository

More Repositories

1

dplyr-cli

Manipulate CSV files on the command line using dplyr
R
269
star
2

ggrgl

3d extension to ggplot
R
182
star
3

ggsvg

Use SVG images as ggplot points
R
138
star
4

emphatic

Highlighting R output in the console
R
137
star
5

yyjsonr

Fast JSON package for R
C
124
star
6

devout

Write R graphics output devices in plain R
C++
97
star
7

anotherworld

AnotherWorld ported to R
R
75
star
8

ggreverse

Reverse a ggplot object back into code
R
67
star
9

eventloop

Event Loop in R
R
65
star
10

isocubes

R
61
star
11

nara

nativeRaster tools for R
C
60
star
12

wordle

Wordle helper for RStats
R
59
star
13

devoutsvg

Bespoke SVG graphics output device with pattern fill support
R
57
star
14

rllama

Minimal R wrapper for llama.cpp
C
55
star
15

carelesswhisper

Automatic speech recognition in R using whisper.cpp
C
54
star
16

svgparser

Render SVG images in R. Load SVG data as data.frames
R
48
star
17

ggthreed

3d geoms and stats for ggplot
R
46
star
18

threed

Three-Dimensional Object Transformations
R
43
star
19

minipdf

Minimal pure-R PDF document creator
R
41
star
20

gluestick

Simple, single-function string interpolation in Base R
R
41
star
21

tr808r

TR-808 Drum Machine for R
R
40
star
22

xxhashlite

Very fast hash functions using xxHash
C++
36
star
23

facetious

Home to some alternate facetting for ggplot2
R
36
star
24

geomlime

ggplot geom_lime()
R
34
star
25

ggblur

Blurry Point Geom for ggplot2
R
34
star
26

fugly

Extract named substrings using named capture groups in regular expressions.
R
34
star
27

rbytecode

R bytecode assembler/disassembler
R
34
star
28

minicss

Build CSS selectors, styles and stylesheets within R
R
31
star
29

minisvg

Create SVG documents with R
R
29
star
30

zstdlite

Fast, configurable in-memory compression of R objects with zstd
C
26
star
31

numberwang

numbers to words and vice versa
R
25
star
32

pacman

Pacman-ish game in R
R
24
star
33

wingspan

Data about the birds and bonus cards in the boardgame "Wingspan"
R
24
star
34

memoisetools

a collection of additional caches and helper functions to work alongside the memoise package
R
23
star
35

terse

Terse output for nested lists and data.frames
R
22
star
36

ransid

Convert images to ANSI with R
R
21
star
37

lz4lite

Very Fast compression/decompression of in-memory numeric vectors with LZ4
C
20
star
38

miranda

Fast PRNGs for R
C
20
star
39

hershey

Hershey vector font data for RStats
R
20
star
40

chipmunkcore

R wrapper around the Chipmunk2d physics simulation library
C
19
star
41

simplercpp

A demo R package incorporating C code with Rcpp
C++
19
star
42

minihtml

A package for building HTML documents in R (shiny compatible)
R
18
star
43

simplecall

A demo R package incorporating C code which is called with .Call()
C
18
star
44

callme

Easily compile inline C code for R
R
17
star
45

foist

Fast Output of Images
C++
17
star
46

RStudioConf-2022

17
star
47

minidrawio

Create simple draw.io documents from R
R
16
star
48

displease

Non-linear numeric interpolation
R
16
star
49

CP1919

Cambridge Pulsar at 19 hours and 19 minutes right ascension
R
16
star
50

purler

Fast run-length encoding with NA support and results as a data.frame
C
16
star
51

fastpng

Read/write 8-bit/16-bit PNGs with rasters, native rasters, numeric+integer arrays, indexed images with palette, packed pixels in raw vector. Configurable compression settings allow for speed/size tradeoff.
C
16
star
52

ggqr

ggplot2 geom for QR codes
R
16
star
53

CRAN-checks

Notes about extra CRAN checks
16
star
54

nonogram

Nonogram solver in rstats
R
15
star
55

optout

Optimized Graphics Output
R
15
star
56

ingrid

Tools for interactive grid creation and manipulation in the console
R
15
star
57

gridfont

A version of the 'gridfont' vector font in an R friendly format
R
15
star
58

phon

Tools and Data for the CMU Pronouncing Dictionary
R
14
star
59

rd2list

Convert Rd documentation to a structured, human-readable list
R
14
star
60

flagon

Flags of the World
R
14
star
61

chipmunkbasic

Higher-level R6 wrapper around Chipmunk2d rigid body physics simulation library
R
14
star
62

anon

Anonymous function creation in R and purrr
R
14
star
63

devoutdrawio

R graphics device to output to draw.io XML vector format
R
14
star
64

miniverse

A constellation of packages for document creation in R
R
14
star
65

devoutaudio

An R graphics device which renders to audio
R
13
star
66

image2xlsx

Convert an image to an excel spreadsheet
R
13
star
67

strictlyr

Stricter subset of dplyr
R
13
star
68

insitu

In-place modification of vectors
C
13
star
69

svgpatternusgs

SVG patterns from the U.S. Geological Survey for use within R
R
13
star
70

cstructr

Exposing C structrs to R
C
13
star
71

ggecho

ggplot2 stat for echoing data
R
13
star
72

arcadefont

Oldschool arcade vector font
R
13
star
73

devoutrgl

R graphics device to render to {rgl}
R
13
star
74

rmonocypher

Easy to use encryption tools for R
C
13
star
75

rconnection

Writing a custom connection for R
C
13
star
76

cgrep

Highlighted grep of R objects
R
12
star
77

serializer

Example showing how to access R's serialization functions from C
C
12
star
78

getrect

Partition matrix into single-valued rectangular areas
R
12
star
79

smallfactor

An R factor backed by a raw vector rather than an integer vector.
R
11
star
80

visvalingam

R package for Visvalingam Line Simplification
C
11
star
81

analemmatic

Create analemmatic sundials with R
R
11
star
82

cairocore

Low-level bindings to the CairoGraphics library for fast 2d drawing operations
R
11
star
83

bdftools

Bitmap font tools for R
R
11
star
84

simplefortran

Demo of how Fortran code could be included in an R package
C
10
star
85

svgpatternsimple

Create some simple repeating SVG patterns in R
R
10
star
86

naratext

Render text as nativeRaster images
R
10
star
87

snowcrash

Encode arbitrary objects as PNGs, rasters and rasterGrobs
R
9
star
88

frak

Fractal Generator
C
9
star
89

grrr

Modify function default arguments
R
9
star
90

triangular

Decompose complex polygons into sets of triangles
R
9
star
91

devoutansi

RStats ANSI graphics device
R
9
star
92

codespacer

Setup CodeSpace with RStudio support
Dockerfile
9
star
93

cryogenic

Freezing calls, modifying arguments and evaluating later
R
8
star
94

btnvips

libvips cli wrapper for #RStats (btn = better than nothing)
R
8
star
95

colourlookup

Technical demonstration of hash lookup for R colour names
C
8
star
96

ggdebug

Package to help debug and inspect ggplot stats
R
8
star
97

simplec

Demo R package with C code which is called using ".C()'
C
8
star
98

simpletrie

Simple trie in pure R
R
8
star
99

poissoned

Poisson Disc Sampling in R
R
8
star
100

devoutpdf

A hand-crafted PDF graphics output device written in plain R
R
8
star