[Sciviews-commits] r534 - in pkg: SciViews/R tcltk2 tcltk2/R tcltk2/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 29 21:44:13 CET 2013
Author: phgrosjean
Date: 2013-11-29 21:44:12 +0100 (Fri, 29 Nov 2013)
New Revision: 534
Modified:
pkg/SciViews/R/character.R
pkg/tcltk2/DESCRIPTION
pkg/tcltk2/NEWS
pkg/tcltk2/R/tcltk2-Internal.R
pkg/tcltk2/R/tk2commands.R
pkg/tcltk2/man/tcltk2-package.Rd
pkg/tcltk2/man/tk2commands.Rd
Log:
tcltk2 does not load additional ttk themes at startup any more (done in tk2theme()). It also sets background at same colour for tk widgets
Modified: pkg/SciViews/R/character.R
===================================================================
--- pkg/SciViews/R/character.R 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/SciViews/R/character.R 2013-11-29 20:44:12 UTC (rev 534)
@@ -225,6 +225,9 @@
char.expand(input = x, target = target, nomatch = nomatch)
charMatch <- .Recode(base::charmatch)
+## There is a faster version in data.table! named chmatch, but is does not
+## exactly the same since it expects characters and do no partial matching!
+
charPMatch <- .Recode(base::pmatch)
## Conversion to character string... + creation and test, shorter versions
Modified: pkg/tcltk2/DESCRIPTION
===================================================================
--- pkg/tcltk2/DESCRIPTION 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/DESCRIPTION 2013-11-29 20:44:12 UTC (rev 534)
@@ -1,7 +1,7 @@
Package: tcltk2
Type: Package
-Version: 1.2-5
-Date: 2013-03-10
+Version: 1.2-6
+Date: 2013-11-29
Title: Tcl/Tk Additions
Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
email = "phgrosjean at sciviews.org"))
Modified: pkg/tcltk2/NEWS
===================================================================
--- pkg/tcltk2/NEWS 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/NEWS 2013-11-29 20:44:12 UTC (rev 534)
@@ -1,5 +1,20 @@
= tcltk2 news
+== Version 1.2-6
+
+* No additional ttk themes are loaded on startup any more. The required
+ resources are now loaded on demand in the tk2theme() function [suggested by
+ Milan Bouchet-Valat & John Fox]. Note that the additional themes 'plastik',
+ 'keramik', 'keramik_alt', 'clearlooks' and 'radiance' are not listed any more
+ with tk2theme.list(), unless their resources are loaded using, e.g.,
+ tk2theme("plastik"). Note also that the 'radiance' theme permanently changes
+ fonts used by the Ttk widgets to fonts identical, or close to those used by
+ Ubuntu.
+
+* tk2theme() now tries to set the same background color for old tk widgets than
+ the color used by ttk widgets. Suggested by Milan Bouchet-Valat.
+
+
== Version 1.2-5
* Clarifications of license terms for R code and additional Tcl libraries.
Modified: pkg/tcltk2/R/tcltk2-Internal.R
===================================================================
--- pkg/tcltk2/R/tcltk2-Internal.R 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/R/tcltk2-Internal.R 2013-11-29 20:44:12 UTC (rev 534)
@@ -77,12 +77,13 @@
}')
}
- ## Load additional ttk themes
- try(tclRequire("ttk::theme::plastik"), silent = TRUE)
- try(tclRequire("ttk::theme::keramik"), silent = TRUE)
- try(tclRequire("ttk::theme::keramik_alt"), silent = TRUE)
- try(tclRequire("ttk::theme::clearlooks"), silent = TRUE)
- try(tclRequire("ttk::theme::radiance"), silent = TRUE)
+ ## Load additional ttk themes - No: load only on demand!
+ ## Not done any more on startup, done on demand in tk2theme() now
+ #try(tclRequire("ttk::theme::plastik"), silent = TRUE)
+ #try(tclRequire("ttk::theme::keramik"), silent = TRUE)
+ #try(tclRequire("ttk::theme::keramik_alt"), silent = TRUE)
+ #try(tclRequire("ttk::theme::clearlooks"), silent = TRUE)
+ #try(tclRequire("ttk::theme::radiance"), silent = TRUE)
## Which ttk theme should we use?
## If the user specified a default theme, use it
@@ -98,7 +99,7 @@
try(tk2theme("xpnative"), silent = TRUE)
} else if ("winnative" %in% themes) { # This must be a pre-XP windows
try(tk2theme("winnative"), silent = TRUE)
- } else if (.isUbuntu() && "radiance" %in% themes) {
+ } else if (.isUbuntu()) {
try(tk2theme("radiance"), silent = TRUE)
## Special treatment for Ubuntu: change fonts to Ubuntu and Ubuntu mono
## and use white text on black for tooltips
@@ -126,7 +127,7 @@
## Windows only
if (.Platform$OS.type == "windows") {
- tclRequire("dde") # Version 1.2.2
+ try(tclRequire("dde"), silent = TRUE) # Version 1.2.2
## Not loaded automatically!
#tclRequire("registry") # Version 1.1.3
## Support for winico.dll is drop from version 1.2-1!
@@ -135,7 +136,7 @@
# else
# tcl("load", file.path(libname, pkgname, "libs", "Winico06.dll"))
## Also register the DDE server as TclEval|R
- tk2dde("R")
+ try(tk2dde("R"), silent = TRUE)
}
}
Modified: pkg/tcltk2/R/tk2commands.R
===================================================================
--- pkg/tcltk2/R/tk2commands.R 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/R/tk2commands.R 2013-11-29 20:44:12 UTC (rev 534)
@@ -194,10 +194,20 @@
if (is.null(theme)) { # Get it
res <- getOption("tk2theme")
} else { # Set it to theme
- .Tcl(paste("ttk::style theme use", theme)) # Better to use tile::setTheme?
+ ## First, check if the theme is already loaded... or try loading it
+ loadedThemes <- tk2theme.list()
+ if (!theme %in% loadedThemes) {
+ ## Could be plastik, keramik, keramik_alt, clearlooks, radiance
+ res <- try(tclRequire(paste0("ttk::theme::", theme)), silent = TRUE)
+ if (inherits(res, "try-error"))
+ stop("Ttk theme ", theme, " is not found")
+ }
+ .Tcl(paste("ttk::style theme use", theme)) # Better to use tile::setTheme?
## And save current theme in option "tk2theme"
options(tk2theme = theme)
- res <- theme
+ ## Make sure to homogenize background for old tk widgets (suggested by Milan Bouchet-Valat)
+ .Tcl(paste("tk_setPalette", tclvalue(.Tcl("ttk::style lookup TFrame -background"))))
+ res <- theme
}
return(res)
}
Modified: pkg/tcltk2/man/tcltk2-package.Rd
===================================================================
--- pkg/tcltk2/man/tcltk2-package.Rd 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/man/tcltk2-package.Rd 2013-11-29 20:44:12 UTC (rev 534)
@@ -16,8 +16,8 @@
\tabular{ll}{
Package: \tab tcltk2\cr
Type: \tab Package\cr
-Version: \tab 1.2-5\cr
-Date: \tab 2013-03-10\cr
+Version: \tab 1.2-6\cr
+Date: \tab 2013-11-29\cr
License: \tab LGPL-3 plus see LICENSE file\cr
LazyLoad: \tab yes\cr
}
Modified: pkg/tcltk2/man/tk2commands.Rd
===================================================================
--- pkg/tcltk2/man/tk2commands.Rd 2013-10-29 11:20:40 UTC (rev 533)
+++ pkg/tcltk2/man/tk2commands.Rd 2013-11-29 20:44:12 UTC (rev 534)
@@ -105,6 +105,90 @@
\seealso{ \code{\link{tk2widgets}}, \code{\link{tk2tip}} }
+\examples{
+\dontrun{
+## These cannot be run by examples() but should be OK when pasted
+## into an interactive R session with the tcltk package loaded
+
+tt <- tktoplevel()
+# A label with a image and some text
+file <- system.file("gui", "SciViews.gif", package = "tcltk2")
+
+# Make this a tk2image function...
+Image <- tclVar()
+tkimage.create("photo", Image, file = file)
+
+tlabel <- tk2label(tt, image = Image,
+ text = "A label with an image")
+tkpack(tlabel)
+config(tlabel, compound = "left")
+
+tlabel2 <- tk2label(tt, text = "A disabled label")
+tkpack(tlabel2)
+disabled(tlabel2) <- TRUE
+
+fruits <- c("Apple", "Orange", "Banana")
+tcombo <- tk2combobox(tt, values = fruits)
+tkpack(tcombo)
+tkinsert(tcombo, 0, "Apple")
+
+## Buttons
+tbut <- tk2button(tt, text = "Enabled")
+tbut2 <- tk2button(tt, text = "Disabled")
+tkpack(tbut, tbut2)
+tkconfigure(tbut2, state = "disabled")
+
+tcheck <- tk2checkbutton(tt, text = "Some checkbox")
+tcheck2 <- tk2checkbutton(tt, text = "Disabled checkbox")
+tkconfigure(tcheck2, state = "disabled")
+tcheck3 <- tk2checkbutton(tt, text = "Disabled and selected")
+tkpack(tcheck, tcheck2, tcheck3)
+cbValue <- tclVar("1")
+tkconfigure(tcheck3, variable=cbValue)
+tkconfigure(tcheck3, state = "disabled")
+
+tradio <- tk2radiobutton(tt, text = "Some radiobutton")
+tradio2 <- tk2radiobutton(tt, text = "Disabled and checked")
+tkpack(tradio, tradio2)
+tkconfigure(tradio2, state = "checked")
+tkconfigure(tradio2, state = "disabled")
+
+## Menu allowing to change ttk theme
+topMenu <- tkmenu(tt) # Create a menu
+tkconfigure(tt, menu = topMenu) # Add it to the 'tt' window
+themes <- tk2theme.list()
+themeMenu <- tkmenu(topMenu, tearoff = FALSE)
+if ("alt" %in% themes) tkadd(themeMenu, "command", label = "alt",
+ command = function() tk2theme("alt"))
+if ("aqua" %in% themes) tkadd(themeMenu, "command", label = "aqua",
+ command = function() tk2theme("aqua"))
+if ("clam" %in% themes) tkadd(themeMenu, "command", label = "clam",
+ command = function() tk2theme("clam"))
+tkadd(themeMenu, "command", label = "clearlooks",
+ command = function() tk2theme("clearlooks"))
+if ("classic" %in% themes) tkadd(themeMenu, "command", label = "classic",
+ command = function() tk2theme("classic"))
+if ("default" %in% themes) tkadd(themeMenu, "command", label = "default",
+ command = function() tk2theme("default"))
+tkadd(themeMenu, "command", label = "keramik",
+ command = function() tk2theme("keramik"))
+tkadd(themeMenu, "command", label = "plastik",
+ command = function() tk2theme("plastik"))
+tkadd(themeMenu, "command", label = "radiance (fonts change too)!",
+ command = function() tk2theme("radiance"))
+if ("vista" %in% themes) tkadd(themeMenu, "command", label = "vista",
+ command = function() tk2theme("vista"))
+if ("winnative" %in% themes) tkadd(themeMenu, "command", label = "winnative",
+ command = function() tk2theme("winnative"))
+if ("xpnative" %in% themes) tkadd(themeMenu, "command", label = "xpnative",
+ command = function() tk2theme("xpnative"))
+tkadd(themeMenu, "separator")
+tkadd(themeMenu, "command", label = "Quit", command = function() tkdestroy(tt))
+tkadd(topMenu, "cascade", label = "Theme", menu = themeMenu)
+tkfocus(tt)
+}
+}
+
\keyword{ utilities }
\concept{ Tcl/Tk widgets commands }
More information about the Sciviews-commits
mailing list