To: r-help at stat.math.ethz.ch
Subject: [R] tcltk - text widget with a scrollbar?
Original-Sender: mmiller3 at iupui.edu
From: mmiller3 at iupui.edu (Michael A. Miller)
Date: 13 Aug 2002 11:41:28 -0500
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2
MIME-Version: 1.0
Can anyone show me how to connect a scrollbar to a text widget
using the tcltk library? I'm confused about how to make sure the
two widgets know about each other and how to set up the
appropriate call-backs for scrolling.
The following code should work:
library(tcltk)
top <- tktoplevel()
mytext <- tktext(top)
myscr <- tkscrollbar(top, command = function (...) tkyview(...))
tkconfigure(mytext, yscrollcommand = function(...) tkset(myscr, ...))
tkpack(myscr, side = "right", fill = "y")
tkpack(mytext, fill = "both", expand = TRUE)
Mike
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"John" == John Zhang <jzhang at jimmy.harvard.edu> writes:
> The following code should work:
library(tcltk)
top <- tktoplevel()
mytext <- tktext(top)
myscr <- tkscrollbar(top, command = function (...) tkyview(...))
tkconfigure(mytext, yscrollcommand = function(...) tkset(myscr, ...))
tkpack(myscr, side = "right", fill = "y")
tkpack(mytext, fill = "both", expand = TRUE)
Thanks John,
That almost works. When I run your code and populate the text
widget with
for ( i in seq(100) ) {
tkinsert(mytext,'end', paste(i,'lots of text\n'))
}
I can scroll around in the widget with my scroll mouse, but using
the mouse on the scroll bar slider produces this sort of error:
Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class = "tclObj") :
[tcl] invalid command name "moveto".
Mousing on the other parts of the scroll bar produces this error:
Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class = "tclObj") :
[tcl] invalid command name "moveto".
Mike
P.S. Here's my version info:
R.version
_
platform i386-pc-linux-gnu
arch i386
os linux-gnu
system i386, linux-gnu
status
major 1
minor 5.1
year 2002
month 06
day 17
language R
library(help=tcltk)
tcltk Interface to Tcl/Tk
Description:
Package: tcltk
Version: 1.5.1
Priority: base
Title: Tcl/Tk Interface
Author: R Development Core Team
Maintainer: R Core Team <R-core at r-project.org>
Description: Interface and Language Bindings to Tcl/Tk GUI elements
License: GPL Version 2 or later.
I get the same error messages when I try this with a windows R:
R.version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 1
minor 5.1
year 2002
month 06
day 17
language R
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I can scroll around in the widget with my scroll mouse, but using
the mouse on the scroll bar slider produces this sort of error:
Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class = "tclObj") :
[tcl] invalid command name "moveto".
I think you need tkyview(mytext,...) in the above. Try looking at the
code for demo(tkfaq) if it still refuses to work.
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._