Re: [R] Is it possible to pass a Tcl/Tk component as argument to afunction

From: John Fox <jfox_at_mcmaster.ca>
Date: Thu, 17 May 2007 11:01:44 -0400


Dear Hao,

> -----Original Message-----
> From: hao.liu_at_bms.com [mailto:hao.liu_at_bms.com]
> Sent: Thursday, May 17, 2007 8:29 AM
> To: John Fox
> Cc: r-help_at_stat.math.ethz.ch
> Subject: Re: [R] Is it possible to pass a Tcl/Tk component as
> argument to afunction
>
> John:
>
> Thanks for your reply, I spent some time on this and the
> conclusion is it works:
>
> top<- tktoplevel()
> mainFrame <- tkcanvas(top)
>
> both top and mainFrame can be used as parameters to pass to
> other function. The name, however, will conflict each other
> if they are defined in the same environment, which means if
> you have another top and mainFrame passed to another
> function, the GUIs will get to the same container. To avaoid
> this, better use different name.
>
> I wonder if there is a way for me to create an env and
> eliminate an env dynamically, I will try to get some
> information, but I definitely welcome some quick inputs...
>

Yes, you can create and delete environments, though it's not clear to me why you should have to do so:

> env <- new.env()
> env

<environment: 0x025f7380>
> parent.env(env)
<environment: R_GlobalEnv>
> rm(env)

Regards,
 John

> Thanks
> Hao
>
>
> John Fox wrote:
>
> Dear Hao,
>
> You might take a look at how the Rcmdr package is
> implemented with many
> reusable elements. There is, for example, an
> initializeDialog function.
>
> I hope this helps,
> John
>
> --------------------------------
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox
> --------------------------------
>
>
>
> -----Original Message-----
> From: r-help-bounces_at_stat.math.ethz.ch
> [mailto:r-help-bounces_at_stat.math.ethz.ch] On
> Behalf Of Hao Liu
> Sent: Wednesday, May 16, 2007 8:58 AM
> To: r-help_at_stat.math.ethz.ch
> Subject: [R] Is it possible to pass a Tcl/Tk
> component as
> argument to afunction
>
> hi! All:
>
> I wonder if someone has done this before...
>
> I am writing several functions that conduct statistical
> analysis using a GUI interface by Tcl/Tk, they
> share many
> identical GUI components. What I am trying to
> do now is to
> simplify the code by writing a GUI repository
> for all the
> components they use, thus save effort for code
> maintenance.
>
> Since they all use:
>
> mainFrame <- tkcanvas(top)
>
> --
>
> I wonder if I can write functions that take
> mainFrame as an
> argument, and call those functions from other
> place with
> initialized tkcanvas object. I did not see
> example like this
> and from my *limited* experience with tcltk, I found it
> always need something to be initialized before
> put to use,
> that makes me wonder if this idea will work...
> if it does
> not, any work arounds? like using Macro?
>
> Thanks
> Hao
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>
>
>
>
>
>
>
>



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 May 2007 - 15:14:22 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 May 2007 - 15:31:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.