aboutsummaryrefslogtreecommitdiff
path: root/inst/GUI/simple.R
diff options
context:
space:
mode:
authorjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2013-09-05 13:18:19 +0000
committerjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2013-09-05 13:18:19 +0000
commitaddb6359238596ca98f696da2d33271b851c08ac (patch)
tree4422fc8a8348650882a503f72d68c2bee74dcb51 /inst/GUI/simple.R
parent25c7431bcf8cef4a8eeaa2374ff7c5e48ef86a3c (diff)
Clean up the GUI directory, the old stuff does not really help a lot
git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@89 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
Diffstat (limited to 'inst/GUI/simple.R')
-rw-r--r--inst/GUI/simple.R125
1 files changed, 57 insertions, 68 deletions
diff --git a/inst/GUI/simple.R b/inst/GUI/simple.R
index c1874145..33ab259c 100644
--- a/inst/GUI/simple.R
+++ b/inst/GUI/simple.R
@@ -1,68 +1,57 @@
-# Work in progress - simple GUI for mkin
-w <- gwindow('Simple R GUI for kinetic evaluations', visible=FALSE)
-# Project definition {{{
-pr <- gexpandgroup("Project", cont=w)
-
-n.observed <- 1
-max.n.observed <- 9
-observed.names = c("parent", paste("M", 1:(max.n.observed - 1), sep=""))
-
-prg <- ggroup(horizontal=FALSE, cont = pr)
-prl <- glayout(cont = prg)
-prl[1,1] <- glabel("Number of observed variables", cont=prl)
-prl[1,2] <- (n.observed.gw = gcombobox(
- 1:max.n.observed,
- handler = function(h, ...) {
- n.observed <<- svalue(n.observed.gw)
- filter.expression <- paste("^[1-", n.observed, "]$", sep="")
- observed.gw$filter("Index", filter.expression)
- },
- cont=prl))
-
-observed.gw <- gdf(
- items = data.frame(Index = 1:max.n.observed,
- Name = observed.names, stringsAsFactors=FALSE),
- name = "Names of observed variables",
- width = 500, height=250, cont=prg)
-
-addSpace(prg, 15)
-prf <- gfile("Project file in binary R format (preferably use .RData as extension)",
- container = prg)
-addSpring(prg)
-addSpace(prg, 15)
-pr.ok <- gbutton("save",
- handler=function(h,...) {
- galert(svalue(prf), parent=w)
- }, container=prg)
-
-gbutton("ok", handler = function(h, ...) {
- observed <- observed.gw[1:n.observed,2]
- save(observed, file="observed.RData")
- visible(pr) <- FALSE
- },
- cont=prg
-)
-
-visible(pr) <- TRUE
-# }}}
-
-# Dataset definition
-ds <- gexpandgroup("Datasets", cont=w)
-s <- gdf(data.frame( Author = c("Meier"), Year = "3", Title = "4"),
- name = "Studies",
-cont=ds)
-
-size(s) <- c(800,200)
-visible(ds) <- TRUE
-
-# Model definition
-ms <- gexpandgroup("Models", cont=w)
-visible(ms) <- FALSE
-
-# Evaluation window
-mw <- gframe("Evaluations", cont=w)
-
-# Status bar
-gstatusbar("Powered by gWidgetsWWW", cont = w)
-visible(w) <- TRUE
-# vim: set foldmethod=marker:
+# Simple gWidgetsWWW2 GUI for mkin
+# Set the GUI title and create the parent frame {{{1
+GUI_title <- "Simple Browser based GUI for kinetic evaluations using mkin"
+w <- gwindow(GUI_title)
+sb <- gstatusbar("Powered by gWidgetsWWW2 and Rook", cont = w)
+g <- gframe(GUI_title, cont = w, use.scrollwindow = TRUE, horizontal = FALSE)
+
+# Set default values for project data objects {{{1
+project_file <- "mkin_project_1.RData"
+# Observed variables {{{2
+n.observed <- 2
+observed.names = c("parent", paste("M", 1:(n.observed - 1), sep=""))
+observed.df = data.frame(Index = 1:n.observed,
+ Name = observed.names,
+ Chemical = "NA",
+ stringsAsFactors = FALSE)
+
+# Project definition and file management {{{1
+upload_file_handler <- function(h, ...) # {{{2
+{
+ tmpfile <- normalizePath(svalue(h$obj), winslash = "/")
+ try(load(tmpfile))
+ project_file <<- pr.gf$filename
+ svalue(wf.ge) <- project_file
+ observed.gdf[,] <- observed.df
+}
+save_to_file_handler <- function(h, ...) # {{{2
+{
+ observed.df <- observed.gdf[,]
+ save(observed.df, file = project_file)
+ galert(paste("Saved project contents to", project_file), parent = w)
+}
+
+# Add widgets for project definition to an expandable group {{{1
+prg <- gexpandgroup("Project definition", cont = g)
+
+pr.vg <- ggroup(cont = prg, horizontal = FALSE)
+pr.hg <- ggroup(cont = pr.vg, horizontal = TRUE)
+pr.gf <- gfile(text = "Select project file", cont = pr.hg,
+ handler = upload_file_handler)
+pr.vg2 <- ggroup(cont = pr.hg, horizontal = FALSE)
+pr.hg2 <- ggroup(cont = pr.vg2, horizontal = TRUE)
+glabel("Current project file name is", cont = pr.hg2)
+change_project_file_handler = function(h, ...) {
+ project_file <<- as.character(svalue(h$obj))
+}
+wf.ge <- gedit(project_file, cont = pr.hg2,
+ handler = change_project_file_handler)
+
+gbutton("Save current project contents to this file", cont = pr.vg2,
+ handler = save_to_file_handler)
+
+observed.gdf <- gdf(observed.df, name = "Names of observed variables",
+ width = 500, height = 250, cont = pr.vg)
+observed.gdf$set_column_width(1, 40)
+
+# vim: set foldmethod=marker ts=2 sw=2 expandtab:

Contact - Imprint