[Stacomir-commits] r183 - pkg/stacomir/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Aug 27 12:12:04 CEST 2016
Author: briand
Date: 2016-08-27 12:12:04 +0200 (Sat, 27 Aug 2016)
New Revision: 183
Modified:
pkg/stacomir/R/funSousListeBilanMigrationPar.r
pkg/stacomir/R/utilitaires.r
Log:
Modified: pkg/stacomir/R/funSousListeBilanMigrationPar.r
===================================================================
--- pkg/stacomir/R/funSousListeBilanMigrationPar.r 2016-08-27 10:11:51 UTC (rev 182)
+++ pkg/stacomir/R/funSousListeBilanMigrationPar.r 2016-08-27 10:12:04 UTC (rev 183)
@@ -48,14 +48,11 @@
# initial = 0,
# width = 400),
# envir = .GlobalEnv)
- progwin <- gtkWindow()
- progwin$setTitle("cumul val. quant. par pas de temps")
- progress_bar <- gtkProgressBar()
- gtkWidgetSetSizeRequest(progress_bar,600,100)
- progwin$add(progress_bar)
- progress_bar$setText(get("msg",envir=envir_stacomi)$BilanFonctionnementDF.5)
+ mygtkProgressBar(title="cumul val. quant. par pas de temps",
+ progress_text=get("msg",envir=envir_stacomi)$BilanFonctionnementDF.5)
+
##############################
- on.exit(close(progres))
+ on.exit(dispose(dialog))
on.exit(if(!is.null(req at connection)) odbcClose(req at connection)) # ne pas lancer en debug
##############################"
# recuperation des valeurs possibles du parametre qualitatif (hors boucle)
@@ -83,7 +80,7 @@
while (getnoPasCourant(bilanMigrationPar at pasDeTemps) != -1) {
zz=(getnoPasCourant(bilanMigrationPar at pasDeTemps)+1)/bilanMigrationPar at pasDeTemps@nbStep
- progress_bar$setFraction(progres,zz)
+ progress_bar$setFraction(zz)
gtkMainIterationDo(FALSE)
#utils::setWinProgressBar(progres,zz,title="cumul val. quant. par pas de temps",label=sprintf("%d%% progression",round(100*zz)))
debutPas = as.POSIXlt(currentDateDebut(bilanMigrationPar at pasDeTemps))
Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r 2016-08-27 10:11:51 UTC (rev 182)
+++ pkg/stacomir/R/utilitaires.r 2016-08-27 10:12:04 UTC (rev 183)
@@ -194,3 +194,49 @@
return(listsql)
}
+
+
+#' Progress bar using a gtkdialog, the progress bar is assigned in .GlobalEnv
+#' This progress bar has a button to close. Use
+#' @param title THe title of the bar
+#' @param progress_text The text to display for progression
+#' @param width Width of the progress bar
+#' @param height Height of the progress bar
+#' @param pulse Do you want the widget to pulse
+#' @returnType
+#' @return
+#'
+#' @author cedric.briand
+#' @examples
+#' \dontrun{
+#' mygtkProgressBar("Trial","progress text")
+#' fraction_progressed=seq(0,1,length.out=50)
+#' for(i in fraction_progressed) {
+#' Sys.sleep(0.1)
+#' progress_bar$setFraction(i)
+#' }
+#' dispose(dialog)
+#' }
+#' @export
+mygtkProgressBar<-function(title,progress_text,width=400,height=50,pulse=TRUE){
+# the main window of the progress bar
+ # title="titre"
+ # text="le texte"
+ dialog <- gtkDialog(title=title, NULL, NULL,
+ "gtk-close", GtkResponseType["none"],
+ show = FALSE)
+ assign("dialog",dialog,envir=.Global_env)
+ ## Ensure that the dialog box is destroyed when the user responds.
+ gSignalConnect(dialog, "response", gtkWidgetDestroy)
+
+ ## Add the label, and show everything we've added to the dialog.
+ progress_bar <- gtkProgressBar()
+ assign("progress_bar",progress_bar,.GlobalEnv)
+ gtkWidgetSetSizeRequest(progress_bar,width=width,height=height)
+ dialog[["vbox"]]$add(progress_bar)
+ progress_bar$setText(progress_text)
+ if (pulse) gtkProgressBarPulse(progress_bar)
+ dialog$showAll()
+}
+
+
More information about the Stacomir-commits
mailing list