From: Ruby Student Date: 2013-07-01T05:14:12+09:00 Subject: Help needed drawing a Sudoku board with green shoes --089e013a28603fa17604e064c145 Content-Type: text/plain; charset=ISO-8859-1 Hello Team, I am planning to write a Sudoku program just for the learning experience. I'm first trying to draw the board using *green shoes* (which I am also learning) as my GUI toolkit. As most people know, the most common Sudoku board is a 9x9 array. The 9x9 array is subdivided on 3x3 square. I don't want to go into details as I know that Sudoku is already a very well know game. To make the game easier to follow it is customary to have some kind of division between each 3x3 square. It could be a heavy line or some space. My problem is that I can't find a way to do this with *green shoes*. I am convinced that it is doable as this appears to be something simple, but I can't find the way. I already experimented with many version of my code. Here are the last two versions. The first version correctly draws the board but with no apparent division between the 3x3 squares. The second version stacks all the buttons one after the other. I thought that the *if else end* stmt that I added could do the trick. But it did not. Any help will be appreciated as usual. *FIRST VERSION require "green_shoes" require 'rubygems' Shoes.app :height => 666, :width => 811, :resizable => false do background magenta title (strong("Sudoku")), :size => 26, :align=>'center' para " " para " " @btn = Array.new(9) {Array.new(9) {123456789}} (0..8).each do |r| stack :margin => 3 do flow :width => 866 do (0..8).each do |c| @btn[r][c] = button "123456789", :width => 86, :height => 50 end # End do c end # flow end # End stack end # End do r end # app * *SECOND VERSION * require "green_shoes" require 'rubygems' Shoes.app :height => 666, :width => 811, :resizable => false do background magenta title (strong("Sudoku")), :size => 26, :align=>'center' para " " para " " @btn = Array.new(9) {Array.new(9) {123456789}} (0..8).each do |r| stack :margin => 3 do (0..8).each do |c| if c == 3 or c == 6 flow :width => 866, :margin => 3 do @btn[r][c] = button "123456789", :width => 86, :height => 50 end else flow :width => 866 do @btn[r][c] = button "123456789", :width => 86, :height => 50 end end # if end # End do c end # End stack end # End do r end # app Thank you -- Ruby Student --089e013a28603fa17604e064c145 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello Team,

I am planning to write a Sudoku program just for the learning experience.=
I'm first trying to draw the board using green shoes (= which I am also learning) as my GUI toolkit.
As most people know, the most common Sudoku board is a 9x9 array. The= 9x9 array is subdivided on 3x3 square. I don't want to go into details= as I know that Sudoku is already a very well know game.

To make the game easier to follow it is customary to have some kind of divi= sion between each 3x3 square. It could be a heavy line or some space.
My problem is that I can't find a way to do this with green = shoes. I am convinced that it is doable as this appears to be something= simple, but I can't find the way. I already experimented with many ver= sion of my code. Here are the last two versions.

The first version correctly draws the board but with no apparent = division between the 3x3 squares.
The second version stacks all th= e buttons one after the other. I thought that the if else end stmt t= hat I added could do the trick. But it did not.

Any help will be appreciated as usual.

FIRST VERSION

require "green_shoes&quo= t;
require 'rubygems'

Shoes.app :height =3D> 666, :wid= th =3D> 811, :resizable =3D> false do
=A0=A0 background magenta
=A0=A0 title (strong("Sudoku")), :si= ze =3D> 26, :align=3D>'center'=A0=A0=A0=A0=A0=A0
=A0=A0= =A0 para " "
=A0=A0 para " "

=A0=A0 @btn =3D = Array.new(9) {Array.new(9) {123456789}}

=A0=A0 (0..8).each do |r|
=A0=A0=A0=A0=A0 stack :margin =3D> 3 do=
=A0=A0=A0=A0=A0=A0=A0=A0 flow :width =3D> 866 do
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (0..8).each do |c|
=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 @btn[r][c] =3D button "123456789", :w= idth =3D> 86, :height =3D> 50
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 end # End do c
=A0=A0=A0=A0=A0=A0= =A0=A0 end # flow
=A0=A0=A0=A0=A0 end # End stack
=A0=A0 end # End do r
end # app


SECOND VERSION

require "green_shoes"require 'rubygems'

Shoes.app :height =3D> 666, :width = =3D> 811, :resizable =3D> false do

=A0=A0 background magenta
=A0=A0 title (strong("Sudoku"= ;)), :size =3D> 26, :align=3D>'center'=A0=A0=A0=A0=A0=A0
= =A0=A0=A0 para " "
=A0=A0 para " "

=A0=A0 @bt= n =3D Array.new(9) {Array.new(9) {123456789}}

=A0=A0 (0..8).each do |r|
=A0=A0=A0=A0=A0 stack :margin =3D> 3 do
=A0=A0=A0=A0=A0=A0=A0=A0 (0..8).each do |c|
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 if c =3D=3D 3 or c =3D=3D 6
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 flow :width =3D> 866, :margin =3D> 3 do
=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 @btn[r][c] =3D button "123456789&= quot;, :width =3D> 86, :height =3D> 50
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 end
=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0 else
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 flow :width = =3D> 866 do
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 @btn[= r][c] =3D button "123456789", :width =3D> 86, :height =3D> = 50
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 end=A0=A0=A0=A0=A0=A0=A0= =A0
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 end # if
=A0=A0=A0=A0=A0=A0=A0=A0 end # End do c
=A0=A0=A0=A0=A0 end # End stack
=A0=A0 end # End do r
end # app

Thank you

--
Ruby Student
--089e013a28603fa17604e064c145--