Hi Kindly correct me if I am posting a wrong query in the forum. I am trying to handle my "button:clicked" event. But not able to proceed further. Please help. Following is my code: library(RGtk2) win <- gtkWindowNew(type = NULL, show = TRUE) butt <- gtkButtonNewWithLabel("Submit", show = TRUE) win$Add(butt) Now I want to do something when my button is clicked. How can I grab the "clicked" signal and define actions against it? Thanks in advance. -- Regards Sarthi M. [[alternative HTML version deleted]]
Sarthi, See help(gSignalConnect) for instructions on how to connect to GObject signals. For this particular case, try gSignalConnect(butt, "clicked", function(wid) print("clicked!")). See the demos included in the RGtk2 paper for numerous examples of using gSignalConnect(). Michael On 3/13/07, hadley wickham <h.wickham@gmail.com> wrote:> > ---------- Forwarded message ---------- > From: d. sarthi maheshwari <samay.sar@gmail.com> > Date: Mar 13, 2007 5:41 AM > Subject: [R] gtk button: how to create signal handler? > To: r-help@stat.math.ethz.ch > > > Hi > > Kindly correct me if I am posting a wrong query in the forum. > > I am trying to handle my "button:clicked" event. But not able to proceed > further. Please help. > Following is my code: > > library(RGtk2) > > > win <- gtkWindowNew(type = NULL, show = TRUE) > butt <- gtkButtonNewWithLabel("Submit", show = TRUE) > win$Add(butt) > > Now I want to do something when my button is clicked. How can I grab the > "clicked" signal and define actions against it? > > Thanks in advance. > > -- > Regards > Sarthi M. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
d. sarthi maheshwari <samay.sar <at> gmail.com> writes:> > Hi > > Kindly correct me if I am posting a wrong query in the forum. > > I am trying to handle my "button:clicked" event. But not able to proceed > further. Please help. > Following is my code: > > library(RGtk2) > > win <- gtkWindowNew(type = NULL, show = TRUE) > butt <- gtkButtonNewWithLabel("Submit", show = TRUE) > win$Add(butt) > > Now I want to do something when my button is clicked. How can I grab the > "clicked" signal and define actions against it? >Dear Sarthi, If you aren't in need of the full power of GTK (which Michael's suggestion gives you), you might want to look at the gWidgets and gWidgetsRGtk2 package which simplify GUI construction a bit: require(gWidgets) gbutton("submit", cont=gwindow("example"), handler=function(h,...) { cat("your action goes here\n") }) The gWidgets package has a vignette with more demos. --John> Thanks in advance. > > -- > Regards > Sarthi M. > > [[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. > >