# NOT RUN {
## These cannot be run by examples() but should be OK when pasted
## into an interactive R session with the tcltk package loaded
tt <- tktoplevel()
label.widget <- tklabel(tt, text = "Hello, World!")
button.widget <- tkbutton(tt, text = "Push",
command = function()cat("OW!\n"))
tkpack(label.widget, button.widget) # geometry manager
# see Tk-commands
## Push the button and then...
tkdestroy(tt)
## test for themed widgets
if(as.character(tcl("info", "tclversion")) >= "8.5") {
# make use of themed widgets
# list themes
as.character(tcl("ttk::style", "theme", "names"))
# select a theme -- here pre-XP windows
tcl("ttk::style", "theme", "use", "winnative")
} else {
# use Tk 8.0 widgets
}
# }
Run the code above in your browser using DataLab