[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby/Tk grid

Ftf 3k3

6/12/2009 2:10:00 PM

I want a 23*36 grid and the ability to put widgets at a specified
location (row/column). I've been searching for a while now and I still
can't find any clear documentation.

Can somebody help please?
Regards
--
Posted via http://www.ruby-....

2 Answers

Hidetoshi NAGAI

6/12/2009 11:58:00 PM

0

From: Ftf 3k3 <ftf3k3@gmail.com>
Subject: Ruby/Tk grid
Date: Fri, 12 Jun 2009 23:10:23 +0900
Message-ID: <89d6d9e03593b2685c005e86e5ec618f@ruby-forum.com>
> I want a 23*36 grid and the ability to put widgets at a specified
> location (row/column). I've been searching for a while now and I still
> can't find any clear documentation.

For example,
----------------------------------------------------------------------
require 'tk'

base = TkFrame.new.pack(:expand=>true, :fill=>:both)

TkGrid.rowconfigure(base, 0, 'weight'=>1, 'minsize'=>0)
TkGrid.columnconfigure(base, 0, 'weight'=>1, 'minsize'=>0)

c = TkCanvas.new(base).grid(:row=>0, :column=>0, :sticky=>'news')
c.xscrollbar TkScrollbar.new(base).grid(:row=>1, :column=>0, :sticky=>'ew')
c.yscrollbar TkScrollbar.new(base).grid(:row=>0, :column=>1, :sticky=>'ns')

cwin = TkcWindow.new(c, [0, 0], :window=>(f = TkFrame.new(c)), :anchor=>:nw)
f.bind('Configure'){ c.scrollregion = cwin.bbox }

23.times{|x|
36.times{|y|
TkButton.new(f,:text=>"#{x}x#{y}").grid(:column=>y,:row=>x,:sticky=>'news')
}
}

Tk.mainloop
----------------------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Ftf 3k3

6/13/2009 5:53:00 PM

0

Thanks this was helpful, I did my first Tk interface.
--
Posted via http://www.ruby-....