I have developed a graphical user interface (GUI) in R using gWidgets. Here is some lines of the code:
library(gWidgets)
library(rattle)
library(RGtk2)
library(tcltk)
## Draw main window:
main_win <- gwindow("Advanced FFDFS: 4-day & 8-day forest fire danger
forecasting ", visible= FALSE, toolkit = guiToolkit())
paned <- gpanedgroup ( cont = main_win )
###########
group <- ggroup(horizontal = FALSE, container=paned)
###########
## Adding logo to the Manin Window
frame_1 <- gframe ( "" , cont = group , horizontal = FALSE )
Here, you could see the GUI:
https://www.dropbox.com/s/8wjng4ukfch9t9y/GUI.jpg?dl=0
Everything is Okay, and by hitting "Run", the program starts to work. All the process is showing in R console.
My question:
Is there any way to invoke R console contents to be shown in the developed graphical user interface (GUI)?
Something like this:
https://www.dropbox.com/s/kb6m3sex02g53qj/GUI2.jpg?dl=0
Reason?
The reason why I want to have this in the GUI is that:
1- Users can see what is going on without looking to the R/R-studio.
2- I want to schedule the program to be run everyday (which is another challenge for me later on), so users do not open the R/R-studio.
Any comment or thought would be highly appreciated.
A simple code based on @jverzani comment:
## Draw main window:
main_win <- gwindow("Adv", visible= FALSE, toolkit = guiToolkit())
button.group_run <- ggroup(container = main_win)
## Push buttons to right
addSpring(button.group_run)
obj_run <- gbutton("Run", container=button.group_run,
handler = function(h,...) gmessage("Good, let me run the model"))
obj_cancel <- gbutton("Cancel", handler = function(h,...) dispose(main_win),
container=button.group_run)
obj_help <- gbutton("Help", container=button.group_run,
handler = function(h,...) gmessage("Test"))
visible ( main_win ) <- TRUE
## Do these when user clicks on Run button:
addhandlerchanged(obj_run, handler=function(h,...)
{
r_console_aa <- capture.output(
print("What is your Username?")
print("NA")
getwd()
)
r_console_aa
})
r_console_aa