tkBinds: Define Tk Binds To Allow Automatic Resizing

Description Usage Arguments Details Examples

View source: R/functions.R

Description

Add binds to automatically resize the graph

Usage

1
tkBinds(parent, expose = TRUE, configure = TRUE)

Arguments

parent

parent Tk toplevel window

expose

if TRUE update graph when the window is expose

configure

if TRUE update the graph when the window is update

Details

This function adds the binds needed to automatically resize the graph

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Not run: 
tkbb <- tclVar(1)
tt <- tktoplevel()
tt <- tkRplot(tt, function() {
b <- .tcl2num(tkbb)
 x <- 1:20 / 20
   plot(
   x,
   x ^ b,
   col = "#0000ff50",
       xlab = "x",
           ylab = paste0("x^", b),
               type = "l",
                   axes = FALSE,
                       lwd = 4)
   title(main = b)
     points(x,
      x ^ b,
      col = "#ff000050",
      pch = 19,
      cex = 2)
        axis(1)
        axis(2)
          box()
          })

       s <-
       tkscale(
       tt,
       from = 0.05,
       to = 2.00,
       variable = tkbb,
       showvalue = FALSE,
       resolution = 0.05,
       orient = "horiz"
       )

       tkpack(s,
       side = "bottom",
       before = tt$env$canvas,
       expand = FALSE,
       fill = "both")

 # to disable the automatic resizing of the graph
   tkBinds(parent = tt, expose = FALSE, configure = FALSE)

 # to enable again the automatic resising
 # tkBinds(parent = tt, expose = TRUE, configure = TRUE)

## End(Not run)

tkRplotR documentation built on June 27, 2021, 5:08 p.m.