Chega de problemas para os usuários do R, o programador poderá adicionar a parte gráfica em seus algoritmos e facilitar a vida para o usuário. Veja exemplo abaixo.
#############################################################
require(tcltk)
mydialog <- function(){
xvar <- tclVar("")
yvar <- tclVar("")
zvar <- tclVar("")
tt <- tktoplevel()
tkwm.title(tt,"Meu programa")
x.entry <- tkentry(tt, textvariable=xvar)
y.entry <- tkentry(tt, textvariable=yvar)
z.entry <- tkentry(tt, textvariable=zvar)
reset <- function() {
tclvalue(xvar)<-""
tclvalue(yvar)<-""
tclvalue(zvar)<-""
}
reset.but <- tkbutton(tt, text="Apagar", command=reset)
submit <- function() {
x <- as.numeric(tclvalue(xvar))
y <- as.numeric(tclvalue(yvar))
z <- as.numeric(tclvalue(zvar))
tkmessageBox(message=paste("x + y + z = ", x+y+z, ""))
}
submit.but <- tkbutton(tt, text="Somar", command=submit)
quit.but <- tkbutton(tt, text = "Fechar sessão!",
command = function() {
q(save = "Não")
tkdestroy(tt)
}
)
tkgrid(tklabel(tt,text="Coloque suas variáveis.."),columnspan=3, pady = 10)
tkgrid(tklabel(tt,text="variável x"), x.entry, pady= 10, padx= 10)
tkgrid(tklabel(tt,text="variável y"), y.entry, pady= 10, padx= 10)
tkgrid(tklabel(tt,text="variável z"), z.entry, pady= 10, padx= 10)
tkgrid(submit.but, reset.but, quit.but, pady= 10, padx= 10)
}
mydialog()
##############################################################
Fonte: R-bloggers
Nenhum comentário:
Postar um comentário