tk2theme               package:tcltk2               R Documentation

_S_e_t _o_r _g_e_t _t_h_e _t_h_e_m_e _i_n _u_s_e _f_o_r _t_h_e_m_e_d _w_i_d_g_e_t_s (_t_i_l_e)

_D_e_s_c_r_i_p_t_i_o_n:

     In tcltk2, we propose a replacement for standard tcltk widgets.
     These new widgets can be "themed", that is, adapted to take
     various visual appearances. It can get the visual appearance of
     various Unix/Linux systems, of Windows (including XP) and of Aqua
     under MacOS. Custom themes can also be defined, or imported from
     GTK.

_U_s_a_g_e:

       tk2theme(theme = NULL)
       tk2theme.list()
       tk2theme.elements()

_A_r_g_u_m_e_n_t_s:

   theme: The new theme to use 

_V_a_l_u_e:

     A list of available themes for 'tk2therme.list()' or of theme
     elements for 'tk2theme.elements()'

_N_o_t_e:

     Themes are provided by the tk package Tile (currently in version
     0.6.2). It is automatically installed under Windows, but for other
     platforms, you must download and compile Tile yourself
     (http://tktable.sourceforge.net/tile/)

_A_u_t_h_o_r(_s):

     Philippe Grosjean

_S_e_e _A_l_s_o:

     'tk2widgets', 'tk2tip'

_E_x_a_m_p_l_e_s:

       ## Not run: 
         ## These cannot be run by examples() but should be OK when pasted
         ## into an interactive R session with the tcltk package loaded

             ## Test all themes one after the other on the demo window
         tk2demo <- function() {
             tt <- tktoplevel()
             tktitle(tt) <- "tk2 demo"

             ## Change icon (under Windows)
             Info <- tk2ico.load(res = "information")
             tk2ico.set(tt, Info)
             tk2ico.destroy(Info)

             ## Add a menu with quit and all themes
             topMenu <- tk2menu(tt)
             tkconfigure(tt, menu = topMenu)
             fileMenu <- tk2menu(topMenu, tearoff = FALSE)
             tkadd(fileMenu, "command", label = "Quit",
                     command = function() tkdestroy(tt))
             tkadd(topMenu, "cascade", label = "File", menu = fileMenu)
             Themes <- sort(tk2theme.list())
             themeMenu <- tk2menu(topMenu, tearoff = FALSE)
             for (i in 1:length(Themes)) {
                     tkadd(themeMenu, "command", label = Themes[i],
                             command = eval(parse(text = paste("function() tk2theme(\"", Themes[i], "\")",
                         sep = ""))))
             }
             tkadd(topMenu, "cascade", label = "Theme", menu = themeMenu)

             #### TO DO: Add a toolbar

             ## Add a notebook with three tabs
             nb <- tk2notebook(tt)
             tcli1 <- tk2frame(nb)
             tkadd(nb, tcli1, text = "Tab 1")
             tcli2 <- tk2label(nb, text = "Nothing here.")
             tkadd(nb, tcli2, text = "Tab 2")
             tcli3 <- tk2label(nb, text = "Nothing here either.")
             tkadd(nb, tcli3, text = "Tab 3")
             tkselect(nb, tcli1)
             tkgrid(nb)

             ## Add a labelframe with new tile widgets
             tfrm1 <- tk2labelframe(tcli1, text = "tile widgets")
             tkgrid(tfrm1)

             # Add a label
             tlab <- tk2label(tfrm1, text = "This is a label... hover me to see a tooltip")
             tkgrid(tlab)
             # Define a tooltip for the label
             tk2tip(tlab, "A tooltip for the label \ndisplayed on two lines")

             # Add a button
             but <- tk2button(tfrm1, text = "Click me", width = 12,
                     command = function() tkmessageBox(title = "tk2 demo",
                             message = "Hello, world!", icon = "info", type = "ok"))
             tkgrid(but)

             # Add a checkbutton
             tcb <- tk2checkbutton(tfrm1, text = " A check button")
             tkgrid(tcb)

             # Add radio buttons
             rbValue <- tclVar("oranges")
             rb1 <- tk2radiobutton(tfrm1, text = " Apples", variable = rbValue,
                     value = "apples")
             rb2 <- tk2radiobutton(tfrm1, text = " Oranges", variable = rbValue,
                     value = "oranges")
             tkgrid(rb1, sticky = "w")
             tkgrid(rb2, sticky = "w")

             # Add a progressbar
             tprog <- tk2progress(tfrm1, orient = "horizontal", from = 0,  to = 100)
             tkgrid(tprog)
             tkset(tprog, 0.5)

             # Add a slider #### TO DO: fix command!
             tscal <- tk2scale(tfrm1, orient = "horizontal", from = 0, to = 100,
                     command = tkset(tprog, 0.2))
             tkgrid(tscal)

             ## Add a labelframe with additional widgets
             tfrm2 <- tk2labelframe(tcli1, text = "additional widgets", width = 50)
             tkgrid(tfrm2)

             # Add a combobox
             cb <- tk2combobox(tfrm2, value = "Banana")
             tkgrid(cb)
             # Fill the combobox list
             fruits <- c("Apple", "Orange", "Banana", "Pear")
             # TO DO: change this!!!
                 #for (i in (1:4))
             #    tk2listinsert(cb, "end", fruits[i])
                 tkinsert(cb, "end", "pear")

             tkfocus(tt)
             return(TRUE)
         }

         tk2demo()
         themes <- tk2theme.list()
         for (i in 1:length(themes)) {
             tk2theme(themes[i])
             Sys.sleep(2)
         }
       ## End(Not run)

