it's work:

require(tcltk)
tt <- tktoplevel(borderwidth=10)

A.but <- tkbutton(tt,text="A",command=function()ls())
B.but <- tkbutton(tt,text="B",command=function()ls())
C.but <- tkbutton(tt,text="C",command=function()ls())
D.but <- tkbutton(tt,text="D",command=function()ls())


tkgrid(A.but,row=0,column=1-1,columnspan=2,rowspan=2,sticky="nswe")
tkgrid(B.but,row=2,column=1-1,columnspan=2,rowspan=1,sticky="nswe")
tkgrid(C.but,row=0,column=3-1,columnspan=2,rowspan=1,sticky="wens")
tkgrid(D.but,row=1,column=3-1,columnspan=2,rowspan=2,sticky="wens")


sapply(0:3, function(i) {
  if(i < 3) tkgrid.rowconfigure(tt, i, weight = 1)
  tkgrid.columnconfigure(tt, i, weight = 1)
})


thanks again

2012/7/16 vincent guyader <vincent.guya...@gmail.com>

> thanks for your answer, i will try this.
>
> Regards
>
>
> 2012/7/16 j verzani <jverz...@gmail.com>
>
>> vincent guyader <vincent.guyader <at> gmail.com> writes:
>>
>> >
>> > Hi everybody,
>> >
>> > I have a problem with the grid function in tk.
>> > I juste try to put 4 buttons like this:
>> >
>> > -------------------
>> > |        |        |
>> > |        |   C    |
>> > |   A    |--------|
>> > |        |        |
>> > ----------   D    |
>> > |        |        |
>> > |   B    |        |
>> > -------------------
>> >
>> > A is 2x2
>> > C is 1x2
>> > B is 1x2
>> > D is 2x2
>> >
>> > but the code bellow dont work :
>> >
>> > require(tcltk)
>> > tt <- tktoplevel(borderwidth=10)
>> >
>> > A.but <- tkbutton(tt,text="A",command=function()ls())
>> > B.but <- tkbutton(tt,text="B",command=function()ls())
>> > C.but <- tkbutton(tt,text="C",command=function()ls())
>> > D.but <- tkbutton(tt,text="D",command=function()ls())
>> >
>> > tkgrid(A.but,row=1,column=1,columnspan=2,rowspan=2,sticky="nswe")
>> > tkgrid(B.but,row=3,column=1,columnspan=2,rowspan=1,sticky="nswe")
>> > tkgrid(C.but,row=1,column=3,columnspan=2,rowspan=1,sticky="wens")
>> > tkgrid(D.but,row=3,column=3,columnspan=2,rowspan=2,sticky="wens")
>> >
>> > any idea?
>> >
>>
>> The row for D.but should be 2, not 3 though I would index at 0 not 1:
>>
>>
>>
>> tkgrid(A.but,row=1-1,column=1-1,columnspan=2,rowspan=2,sticky="nswe")
>> tkgrid(B.but,row=3-1,column=1-1,columnspan=2,rowspan=1,sticky="nswe")
>> tkgrid(C.but,row=1-1,column=3-1,columnspan=2,rowspan=1,sticky="wens")
>> tkgrid(D.but,row=3-1-1,column=3-1,columnspan=2,rowspan=2,sticky="wens")
>>
>>
>> Then to get the buttons to expand into the allocated sace, you can
>> configure
>> the row and column weights:
>>
>> sapply(0:3, function(i) {
>>   if(i < 3) tkgrid.rowconfigure(tt, i, weight = 1)
>>   tkgrid.columnconfigure(tt, i, weight = 1)
>> })
>>
>>
>>
>>
>>
>> > thx
>> >
>> > Vincent
>> >
>> >       [[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.
>>
>
>

        [[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