Hao Liu
2007-May-16 12:58 UTC
[R] Is it possible to pass a Tcl/Tk component as argument to a function
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]]
John Fox
2007-May-16 13:15 UTC
[R] Is it possible to pass a Tcl/Tk component as argument to afunction
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. >
Duncan Murdoch
2007-May-16 13:18 UTC
[R] Is it possible to pass a Tcl/Tk component as argument to a function
On 5/16/2007 8:58 AM, Hao Liu wrote:> 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?I think your question is too vague. Yes, you can pass your mainFrame object to a function. Will it work? Well, that depends on what you do with it. Could you put together a small example showing the sort of thing you want to do? If it works, then you probably don't need to post a question; if it doesn't, someone can probably point out what changes are necessary. Duncan Murdoch