[R] help with tktag.bind

solares@unsl.edu.ar solares at unsl.edu.ar
Mon Jul 19 23:59:38 CEST 2004


Hi, i newbee in R and not understand the command tktag.bind, the code below
not work find, (not change the foreground to red at move the cursos on the
lines in the tktext and the for sentence appear not work) Why is
this?Thanks


library(tcltk)
tt<-tktoplevel()
editor<-tktext(tt)
tkpack(editor)
tkinsert(editor,"1.0","first line \n")
tkinsert(editor,"2.0","Second line \n")
tkinsert(editor,"3.0","Third line \n")

cambio1<-function(t){
         tktag.configure(editor,t,foreground="red")
         }
cambio2<-function(t){
         tktag.configure(editor,t,foreground="black")
         }

tktag.add(editor,"t1","1.0","1.end")
tktag.add(editor,"t2","2.0","2.end")
tktag.add(editor,"t3","3.0","3.end")
tkbind(editor,"<ButtonPress-1>",cambio1)
tkbind(editor,"<ButtonRelease-1>",cambio2)
hello<-function() print("hello")
tktag.bind(editor,"t1","<1>",hello)
tktag.bind(editor,"t1","<Motion>",cambio1(t1))
tktag.bind(editor,"t1","<Leave>",cambio2(t1))

l<-c("t1","t2","t3")
for (t in l) 
tktag.bind(editor,t,"<Motion>",tktag.configure(editor,t,foreground="red"))
for (t in l) 
tktag.bind(editor,t,"<Leave>",tktag.configure(editor,t,foreground="black"))




More information about the R-help mailing list