An open API service indexing awesome lists of open source software.

https://github.com/digoarthur/gui-for-r

Create a graphical interface for your functions in R and analyze them more dynamically.
https://github.com/digoarthur/gui-for-r

gui interface-builder r research tcl-tk

Last synced: about 2 months ago
JSON representation

Create a graphical interface for your functions in R and analyze them more dynamically.

Awesome Lists containing this project

README

          

GUI for R ft. Tcl/Tk





bashftreactgit


Create a graphical interface for your functions in R and analyze them more dynamically.





`based in` :

[Dalgaard, Peter. "A primer on the R-Tcl/Tk package." R News 1.3 (2001): 27-31.][3]

and

[midrangeMCP][4] / [Repository](https://github.com/bendeivide/midrangeMCP/)




![GitHub last commit](https://img.shields.io/github/last-commit/digoarthur/GUI-for-R
)
![GitHub](https://img.shields.io/github/license/digoarthur/GUI-for-R
)





# skills About Application
---
> The creation of graphical interfaces is to facilitate user interaction with the resources that programming brings.
> In the R language, there is a library called tcl/tk responsible for generating widgets.

---


# skills Example Interface





# skills About Tcl/Tk

> (...) R does not incorporate a statistical graphical user interface (GUI), but it does include tools for building GUIs.
> Based on the tcltk package (which furnishes an interface to the Tcl/Tk GUI toolkit) (...)
>
> -- [FOX, J. The R Commander: A Basic-Statistics Graphical User Interface to R. Journal of Statistical Software, [S. l.], v. 14, n. 9, p. 1–42, 2005. DOI: 10.18637/jss.v014.i09.][1]

> Tcl/Tk is a combination of a scripting language and a toolkit for graphical user interfaces. Since version 1.1.0, R has had a tcltk package to access the Tk
> toolkit, replacing Tcl code with R function calls [(Dalgaard, 2001)][2]. There are still some design problems in it, but it is quite useful already in its current state.
>
> -- [Dalgaard, Peter. "A primer on the R-Tcl/Tk package." R News 1.3 (2001): 27-31.][3]



## skills Example Application


### Simple GUI application


bashftreactgit

```R
tt <- tktoplevel()
tkwm.title(tt,'Simple GUI application')
tkwm.geometry(tt, "600x400")
lbl <- tklabel(tt, text="Hello, World!")
tkpack(lbl)
```

----

### Simple GUI application and Button


bashftreactgit

```R
library(tcltk)
tt <- tktoplevel()
tkwm.title(tt,'Simple GUI application and Button')
lbl <- tklabel(tt, text="Hello, World!")
tkpack(lbl)
but <- tkbutton(tt, text="OK")
tkpack(but)

```

----

### Widget Directions


bashftreactgit

```R
tkdestroy(tt) # get rid of old example
tt <- tktoplevel()
tkwm.title(tt,'Widget Directions')
edge <- c("top","right","bottom","left")
buttons <- lapply(1:4,
function(i) tkbutton(tt, text=edge[i]))
for ( i in 1:4 )
tkpack(buttons[[i]], side=edge[i],
fill="both")
```

----

### Grid Managers, Positions


bashftreactgit

```R
t2 <- tktoplevel()
tkwm.title(t2,'Grid Managers, Positions')
heading <- tklabel(t2, text="Registration form")
l.name <- tklabel(t2, text="Name")
l.age <- tklabel(t2, text="Age")
e.name <- tkentry(t2, width=30)
e.age <- tkentry(t2, width=3)
tkgrid(heading, columnspan=2)
tkgrid(l.name, e.name)
tkgrid(l.age, e.age)
tkgrid.configure(e.name, e.age, sticky="w")
tkgrid.configure(l.name, l.age, sticky="e")
```

----

### Creating menus


bashftreactgit

```R
# Creating menus
tclvar$color<-"blue"
tt <- tktoplevel()
tkpack(mb <- tkmenubutton(tt, text="Color"))
m <- tkmenu(mb)
tkwm.title(tt,'Creating menus')
tkconfigure(mb,menu=m)
for ( i in c("red", "blue", "green"))
tkadd(m, "radio", label=i, variable="color",
value=i)
```
----

### A simple application: Scripting widgets


bashftreactgit

```R
tkscript <- function() {
wfile <- ""
tt <- tktoplevel()
tkwm.title(tt,'A simple application: Scripting
widgets
')
txt <- tktext(tt, height=10)
tkpack(txt)
save <- function() {
file <- tkcmd("tk_getSaveFile",
initialfile=tkcmd("file", "tail", wfile),
initialdir=tkcmd("file", "dirname", wfile))
if (!length(file)) return()
chn <- tkcmd("open", file, "w")
tkcmd("puts", chn, tkget(txt,"0.0","end"))
tkcmd("close", chn)
wfile <<- file
}
load <- function() {
file <- tkcmd("tk_getOpenFile")
if (!length(file)) return()
chn <- tkcmd("open", file, "r")
tkinsert(txt, "0.0", tkcmd("read", chn))
tkcmd("close", chn)
wfile <<- file
}
run <- function() {
code <- tkget(txt,"0.0","end")
e <- try(parse(text=code))
if (inherits(e, "try-error")) {
tkcmd("tk_messageBox",
message="Syntax error",
icon="error")
return()
}
cat("Executing from script window:",
"-----", code, "result:", sep="\n")
print(eval(e))
}
topMenu <- tkmenu(tt)

tkconfigure(tt, menu=topMenu)
fileMenu <- tkmenu(topMenu, tearoff=FALSE)
tkadd(fileMenu, "command", label="Load",
command=load)
tkadd(fileMenu, "command", label="Save",
command=save)
tkadd(topMenu, "cascade", label="File",
menu=fileMenu)
tkadd(topMenu, "command", label="Run",
command=run)
}

```

----

### Canvas


bashftreactgit

```R
# Main Window
base <- tktoplevel(padx=10, pady=10)
tkwm.geometry(base, "600x400")
# Change title using tk window manager
tkwm.title(base,'Canvas')
# Main Window Frame
main_frame <- tkframe(base, relief="sunken", borderwidth = 1)

# Canvas
canvas <- tkcanvas(main_frame)

tkpack(main_frame, canvas, fill = "both", expand=TRUE)
#tkpack(main_frame, fill = "both", expand=TRUE)

tkconfigure(canvas, "-background", "#483D8B")
```



## skills Motivation

I built this repository to share with the community, especially those who work with the R Language, the possibility of building Graphical Interfaces. This project [midrangeMCP][4], the result of research at the Federal University of São João del-Rei, where I collaborated, was the beginning of research into a construction language for the application of Statistics functionalities . Through research we found Tcl/Tk. I hope it is of good use. Hugs.

PS: I want to thank my Advisor [Ben Dêivide](https://bendeivide.github.io/#about), and my [Federal University of São João del-Rei](https://www.ufsj.edu.br). 💜



## skills References


[FOX, J. The R Commander: A Basic-Statistics Graphical User Interface to R. Journal of Statistical Software, [S. l.], v. 14, n. 9, p. 1–42, 2005. DOI: 10.18637/jss.v014.i09.][1]

[Dalgaard, P. (2001). The R-tcl/tk interface. In Proceedings of DSC (Vol. 1, No. 2).][2]

[Dalgaard, P. (2001). A primer on the R-Tcl/Tk package. R News, 1(3), 27-31.][3]

[Ben Deivide and Daniel Furtado (NA). midrangeMCP: Multiples Comparisons Procedures Based on Studentized Midrange and Range Distributions.][4]

[Ospina G., J. (2015). Uso de la librería TCL/TK en el desarrollo de una interfaz gráfica de usuario (GUI) en R. ][5]





[1]: https://www.jstatsoft.org/article/view/v014i09
[2]: https://www.r-project.org/conferences/DSC-2001/Proceedings/Dalgaard.pdf
[3]: https://cran.uni-muenster.de/doc/Rnews/Rnews_2001-3.pdf#page=27
[4]: https://bendeivide.github.io/midrangeMCP/
[5]: https://bibliotecadigital.univalle.edu.co/entities/publication/4207e598-1091-4336-9a3d-263e2050212a