Hello, how do I centralize the texts inside a RTclTk listbox?

 

The code I am using is:

 

require(tcltk)

tt<-tktoplevel()

tl<-tklistbox(tt,height=4,selectmode="single",background="white")

tkgrid(tklabel(tt,text="What's your favorite fruit?"))

tkgrid(tl)

fruits <- c("Apple","Orange","Banana","Pear")

for (i in (1:4)){

  tkinsert(tl,"end",fruits[i])

}

tkselection.set(tl,2)  # Default fruit is Banana.  Indexing starts at zero.

OnOK <- function(){

  fruitChoice <- fruits[as.numeric(tkcurselection(tl))+1]

  tkdestroy(tt)

  msg <- paste("Good choice! ",fruitChoice,"s are delicious!",sep="")

  tkmessageBox(message=msg)

}

OK.but <-tkbutton(tt,text="   OK   ",command=OnOK)

tkgrid(OK.but)

tkfocus(tt)

 

Thanks!


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to