[R] mouse position with package tcltk
solares@unsl.edu.ar
solares at unsl.edu.ar
Mon Jan 10 15:02:13 CET 2005
HI, i need a know what is wrong with this code. If you run then not known,
X0, W or XPlace. This code not accept parameter but in tcl yes.
This code make a window panned. Thanks Ruben
In R:
library(tcltk)
XPlace<-function(fract){
tkcmd("place",nb1,"relwidth"=fract)
tkcmd("place",nb3,"relx"=fract)
#tkcmd("place",nb2,"relwidth"=[expr {1.0 - fract}])
tkcmd("place",nb2,"relwidth"=1.0 - fract)
}
tt<-tktoplevel("background"="black")
w<-.Tk.ID(tt)
nb1<-paste(w,".left",sep="",collapse=".")
nb2<-paste(w,".right",sep="",collapse=".")
nb3<-paste(w,".lrhandle",sep="",collapse=".")
f1<-tkcmd("frame",nb1,"background"="purple","width"=20)
f2<-tkcmd("frame",nb2,"background"="red","width"=20)
f3<-tkcmd("frame",nb3,"borderwidth"=2,"relief"="raised","background"="orange","cursor"="sb_v_double_arrow")
tkcmd("place",nb1,"relheight"=1,"anchor"="nw")
tkcmd("place",nb3,"rely"=.9,"anchor"="e","width"=10,"height"=10)
tkcmd("place",nb2,"relheight"=1,"relx"=1,"anchor"="ne")
tkcmd("bind",nb3,"<Configure>","set W [winfo width .]")
tkcmd("bind",nb3,"<Configure>","set X0 [winfo rootx .]")
tkcmd("bind",nb3,"<B1-Motion>","XPlace [expr {(\"%X\"- $X0)/double($W)}]")
XPlace(.5)
In Tcl/Tk:
proc XPlace {fract} {
place .left -relwidth $fract
place .lrhandle -relx $fract
place .right -relwidth [expr {1.0 - $fract}]
}
frame .left -bg purple -width 20
frame .right -bg red -width 20
frame .lrhandle -borderwidth 2 -relief raised -bg orange -cursor
sb_v_double_arrow
. configure -bg black
place .left -relheight 1 -anchor nw
place .lrhandle -rely .9 -anchor e -width 10 -height 10
place .right -relheight 1 -relx 1 -anchor ne
bind .lrhandle <Configure> {set W [winfo width .]; set X0 [winfo rootx .]}
bind .lrhandle <B1-Motion> {XPlace [expr {(%X-$X0)/double($W)}]}
XPlace .5
pack [ label .left.label -text "Left side" ]
pack [ label .right.label -text "Right side" ]
Why i can pass parameter in Tcl but with function in R not.?
More information about the R-help
mailing list