1

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
Canada2015
  • 187
  • 1
  • 12
  • You might be able to use `capture.output` to grab the results of a command and then display that. – jverzani May 16 '19 at 22:10
  • @jverzani , based on your comment, I edited the question (i.e., added a simple but real code at the end). However, it still does not show the R console for me. Do you have an idea about the new code? Thanks. – Canada2015 May 22 '19 at 17:15
  • Sorry, you don’t get both without more work. If you want it in the GUI only then capture.output can work. – jverzani May 23 '19 at 23:30

0 Answers0