[R-gui] tkcanvas: resize window

Adrian Waddell adrian at waddell.ch
Wed Mar 25 13:51:40 CET 2009


Hello all,

I'm using tkcanvas in a similar way as shown in demo(tkcanvas).

I would like to add a window resizing functionality where the canvas 
objects scale to the window (canvas) size. In order to make the resizing 
smooth, I would like to only display the window size (e.g. "423x356") 
while resizing and then once the mouse button is released, the original 
canvas content should rescale to the window size.

The '<Configure>' event can be used to display the current window size.

What is the name of the event that should trigger the redrawing (i.e. 
release mouse button from resizing the window) ?

And how do I get the current canvas size (maybe you can comment on the 
attached code) ?

tt <- tktoplevel()
canvas <- tkcanvas(tt, relief="raised", width = 200, height = 200)
tkpack(canvas, fill = 'both', expand = TRUE)

## Get whole Window Size, (but I need canvas size)
as.numeric(unlist(strsplit(as.character(tkwm.geometry(tt)),c('[+x]'))))

## stays 200,200, regardless if the window gets resized
tkcget(canvas,width = NULL)
tkcget(canvas,height = NULL)


Sincerely,

Adrian Waddell



More information about the R-SIG-GUI mailing list