Tk grid problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Tk grid problem

vincent guyader-2
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?

thx


Vincent

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Tk grid problem

Peter Dalgaard-2

On Jul 16, 2012, at 16:13 , vincent guyader wrote:

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

I suspect you need to experiment with tkgrid.columnconfigure(...., minsize=...) and the corresponding for rows. Also, you probably didn't intend both B and D to start in row 3.

>
> thx
>
>
> Vincent
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Tk grid problem

jverzaniNWBKZ
In reply to this post by vincent guyader-2
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]]
>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Tk grid problem

vincent guyader-2
thanks for your answer, i will try this.

Regards

2012/7/16 j verzani <[hidden email]>

> 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]]
> >
> >
>
> ______________________________________________
> [hidden email] 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]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: Tk grid problem

vincent guyader-2
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 <[hidden email]>

> thanks for your answer, i will try this.
>
> Regards
>
>
> 2012/7/16 j verzani <[hidden email]>
>
>> 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]]
>> >
>> >
>>
>> ______________________________________________
>> [hidden email] 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]]

______________________________________________
[hidden email] 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.