[R-gui] Example using 'after'
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Oct 13 09:30:23 CEST 2008
Paul Roebuck wrote:
> On Fri, 10 Oct 2008, Peter Dalgaard wrote:
>
>> Paul Roebuck wrote:
>>> 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?
>>>
>> tcl("after", "idle", "bell")
>>
>> or
>>
>> .Tcl("after idle bell")
>>
>> (which starts with a dot because you shouldn't have to know about
>> it....)
>>
>
> 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]
>
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.)
> 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?
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.
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-SIG-GUI
mailing list