From b116635d05647eec6909e844be6034e17ca2f821 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 6 Nov 2015 14:01:56 +0100 Subject: Return the gmkin app from gmkin() and update its documentation --- R/gmkin.R | 28 +++++++++++++++++++++++++++- man/gmkin.Rd | 14 +++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/R/gmkin.R b/R/gmkin.R index 424054e..a5d16fb 100644 --- a/R/gmkin.R +++ b/R/gmkin.R @@ -1,3 +1,21 @@ +# Copyright (C) 2015 Johannes Ranke +# Contact: jranke@uni-bremen.de + +# This file is part of the R package gmkin + +# gmkin is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see + # This makes use of the ::: operator # To avoid this, gWidgetsWWW2 needs to be adapted gmkin <- function(script_name, show.log = FALSE) { @@ -8,10 +26,18 @@ gmkin <- function(script_name, show.log = FALSE) { r_httpd <- gWidgetsWWW2:::R_http$get_instance() r_httpd$start() r_httpd$load_gw(session_manager) - r_httpd$load_app(script_name, "gmkin", session_manager, + gmkin_app <- r_httpd$load_app(script_name, "gmkin", session_manager, open_page = TRUE, show.log = show.log) gmkin_png <- Rook::Static$new( urls = c("/"), root = system.file("GUI/png", package="gmkin")) r_httpd$R$add(Rook::RhttpdApp$new(gmkin_png, name="gmkin_png")) + invisible(gmkin_app) +} + +get_current_session <- function(app) { + s_names <- names(app$session_manager$sessions) + names(app$session_manager$sessions[[s_names[length(s_names)]]]$e) + s_env <- app$session_manager$sessions[[s_names[length(s_names)]]]$e + return(s_env) } diff --git a/man/gmkin.Rd b/man/gmkin.Rd index 2677aa9..f8540ff 100644 --- a/man/gmkin.Rd +++ b/man/gmkin.Rd @@ -23,9 +23,21 @@ } \examples{ \dontrun{gmkin()} # Start the gmkin GUI + \dontrun{ + g <- gmkin() + + # Only for debugging or other advanced usage: + session <- gmkin:::get_current_session(g) + session$p.df + session$ds.df + session$ds.cur + session$m.cur + session$ws + } } \value{ - The function is called for its side effect, namely starting the GUI in a browser. + The function is called for its side effect, namely starting the GUI in a browser. + For the curious, the desperate or the adventurous, the gmkin app (a GWidgetsApp object) is returned. } \author{ Johannes Ranke -- cgit v1.2.1