Skip to content

Instantly share code, notes, and snippets.

@spacedman
Created July 6, 2012 22:27
Show Gist options
  • Save spacedman/3063106 to your computer and use it in GitHub Desktop.
Save spacedman/3063106 to your computer and use it in GitHub Desktop.
Resizing rpanel widgets
# here is a way to make an rpanel dialog wider. Useful when the default skinny
# sliders are not precise enough for fat fingered prodders:
# standard slider demo
density.draw <- function(panel) {
plot(density(panel$x, bw = panel$h))
panel
}
# create panel and add slider. Note aschar=FALSE so we can get the $window:
panel <- rp.control(x = rnorm(50),aschar=FALSE)
rp.slider(panel, h, 0.5, 5, log = TRUE, action = density.draw)
# construct a geometry string with the current height and new width:
h = as.numeric(tkwinfo("height",panel$window))
w = 300
g = sprintf("%dx%d",w,h)
# resize
tkwm.geometry(panel$window,g)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment