[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Help with Shoes

Ruby Student

9/15/2008 11:06:00 PM

[Note: parts of this message were removed to make it a legal post.]

Hello Ruby/Shoes World!
As part of my Ruby learning experience I started looking into a GUI
environment.
Shoes appears to be simple enough that I would probably be able to learn it.
I am working on a simple Sudoku solver in Ruby, as a Ruby learning exercise.
To this point I have been using stray ASCII output, but I would like to
beautify it using GUI.

To that effect, I was looking at some of the Shoes sample programs,
specifically the one named calc.
I selected calc because it shows how to place several buttons on a row.
Although the buttons on calc represents the basic symbols of a calculator, I
thought copying the same concept to represents the 9x9 matrix of a "regular"
sudoku puzzle.

The following is the modified code from calc to display the board, and for
which I have some questions:

Shoes.app(:title => " A Humble
Sudoku Solver ", :height => 546, :width => 617, :resizable => false) do
background "#EEC".."#996", :radius => 5, :top => 2, :left => 2, :width
=> -4, :height => -4
stack :margin => 0 do
stack :margin => 0
btn = "123456789"
flow :width => 618, :margin => 4 do
(1..81).each do |n|
button btn, :width => 66, :height => 66
end
end
end
end

1) - For the title, is there some formatting to tell Shoes to center or
left/right justified a title?
2) - For the background I tried fill green right after the last " (double
quote) but it gave me an error. How could I specified fill green, although I
don't really need it.
3) - What purpose of :radius => 5?
4) - If you are familiar with sudoku, how do you add solid lines to separate
each subgroup of 3x3?

Although I have many more questions, I will continue looking the
documentation, including nks.

Thank you

Ruby Student

3 Answers

_why

9/16/2008 7:14:00 PM

0

On Tue, Sep 16, 2008 at 08:06:27AM +0900, Ruby Student wrote:
> The following is the modified code from calc to display the board, and for
> which I have some questions:
>
> Shoes.app(:title => " A Humble
> Sudoku Solver ", :height => 546, :width => 617, :resizable => false) do
> background "#EEC".."#996", :radius => 5, :top => 2, :left => 2, :width
> => -4, :height => -4
> stack :margin => 0 do
> stack :margin => 0
> btn = "123456789"
> flow :width => 618, :margin => 4 do
> (1..81).each do |n|
> button btn, :width => 66, :height => 66
> end
> end
> end
> end
>
> 1) - For the title, is there some formatting to tell Shoes to center or
> left/right justified a title?

For window titles, no. For titles on the screen, use :align =>
"center".

title "Sudoku Solver", :align => "center"

> 2) - For the background I tried fill green right after the last " (double
> quote) but it gave me an error. How could I specified fill green, although I
> don't really need it.

You want the background to be green, not a gradient?
Try: background(green)

> 3) - What purpose of :radius => 5?

In newer versions of Shoes, this is :curve => 5. It curves the
edges of the background rectangle.

> 4) - If you are familiar with sudoku, how do you add solid lines to separate
> each subgroup of 3x3?

You'll want to group the buttons each in their own slot. (A slot is
the generic name for a `stack` or `flow`.)

Shoes.app(:title => "A Humble Sudoku Solver ", :height => 546,
:width => 640, :resizable => false) do
background green

btn = "123456789"
9.times do
flow :width => 206, :margin => 4 do
9.times do
button btn, :width => 66, :height => 56
end
end
end
end

I don't know if this is helpful or just more confusing, but Martin
DeMello recently wrote a crossword builder. Maybe since sudoku and
crosswords are relatives, it might have some ideas you could use?
<http://gist.github.com...

_why

Ruby Student

9/16/2008 7:48:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Tue, Sep 16, 2008 at 3:13 PM, _why <why@ruby-lang.org> wrote:

> On Tue, Sep 16, 2008 at 08:06:27AM +0900, Ruby Student wrote:
> > The following is the modified code from calc to display the board, and
> for
> > which I have some questions:
> >
> > Shoes.app(:title => " A Humble
> > Sudoku Solver ", :height => 546, :width => 617, :resizable => false) do
> > background "#EEC".."#996", :radius => 5, :top => 2, :left => 2,
> :width
> > => -4, :height => -4
> > stack :margin => 0 do
> > stack :margin => 0
> > btn = "123456789"
> > flow :width => 618, :margin => 4 do
> > (1..81).each do |n|
> > button btn, :width => 66, :height => 66
> > end
> > end
> > end
> > end
> >
> > 1) - For the title, is there some formatting to tell Shoes to center or
> > left/right justified a title?
>
> For window titles, no. For titles on the screen, use :align =>
> "center".
>
> title "Sudoku Solver", :align => "center"
>
> > 2) - For the background I tried fill green right after the last " (double
> > quote) but it gave me an error. How could I specified fill green,
> although I
> > don't really need it.
>
> You want the background to be green, not a gradient?
> Try: background(green)
>
> > 3) - What purpose of :radius => 5?
>
> In newer versions of Shoes, this is :curve => 5. It curves the
> edges of the background rectangle.
>
> > 4) - If you are familiar with sudoku, how do you add solid lines to
> separate
> > each subgroup of 3x3?
>
> You'll want to group the buttons each in their own slot. (A slot is
> the generic name for a `stack` or `flow`.)
>
> Shoes.app(:title => "A Humble Sudoku Solver ", :height => 546,
> :width => 640, :resizable => false) do
> background green
>
> btn = "123456789"
> 9.times do
> flow :width => 206, :margin => 4 do
> 9.times do
> button btn, :width => 66, :height => 56
> end
> end
> end
> end
>
> I don't know if this is helpful or just more confusing, but Martin
> DeMello recently wrote a crossword builder. Maybe since sudoku and
> crosswords are relatives, it might have some ideas you could use?
> <http://gist.github.com...
>
> _why
>
>
_why,

Thank you very much for taking the time to answer my questions. It is really
appreciated.
I will also look and learn from Martin's crosswords puzzle.

Thanks again,

Ruby Student

Marc Heiler

9/16/2008 10:29:00 PM

0

It's _why!

It's GIANT FOXES IN SHOES!

Run!!!!
--
Posted via http://www.ruby-....