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
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
From: Ftf 3k3 [email protected]
Subject: Ruby/Tk grid
Date: Fri, 12 Jun 2009 23:10:23 +0900
Message-ID: [email protected]
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.
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
Thanks this was helpful, I did my first Tk interface.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs