Skip to content

[R-gui] Example using 'after'

4 messages · Paul Roebuck, Peter Dalgaard

#
Does this work when using tcltk package?

I tried the minimalist
    tcl("after idle bell")

but it just gives an error.

Does someone have an example?

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)
#
Paul Roebuck wrote:
tcl("after", "idle", "bell")

or

.Tcl("after idle bell")

(which starts with a dot because you shouldn't have to know about it....)
2 days later
#
On Fri, 10 Oct 2008, Peter Dalgaard wrote:

            
Thanks for responding. How far does this go? This was a
trivial example so I didn't expect much but there appears
to be little support for using "after" in general. If I
have an actual procedure to call, just write the entire
code as a single string and pass it to .Tcl() method?

For instance, if one wanted to set a minimum size for a
Tk application, the Tcl code might be as follows:

after idle [format {
    update idletasks
    wm minsize %s [winfo reqwidth %s] [winfo reqheight %s]
} $top $top $top]


Also, could you (Peter) clarify whether the environment
created with each Tk widget should be considered "private"?
In other words, is storing widget-specific user data
within its environment user-supported functionality?

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)
#
Paul Roebuck wrote:
You're a bit on your own there, in the sense that I can't afford
spending hours to figure out the exact way of doing it. However, notice
that the general picture is that callbacks can be R functions so it
could be something like

tkafter("idle", function() {
    tkupdate("idletasks")
    tkwm("minsize", tt,
         tkwinfo("regwidth", tt),
         tkwinfo("regheight", tt))
})

(Notice that there are predefined shortcuts

tkwm(....) for

tcl("wm", ...) etc.)
They're not intended for that, just to hold widget references and
callback, but I don't see any harm in "abusing" them for other purposes.
The general idea was to use ordinary lexical scoping rules, though.