wxruby and the use of sizers - Help, Please!

R

Ruby Student

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

Hello all you happy people!
I am trying to learn wxruby and to that effect I played with the tutorial,
which is very limited.
I am trying to draw a grid for a sudoku puzzle. I first tried using
GridSizer but then I did not know how to add each cell (button) to the 9x9
grid.
Then I thought that perhaps I should use GridBagSizer for flexibility or
something else.
I need to be able to change the caption of the button, which could have a
number from 1 to 9, dynamically.
Which class should I use and where can I find examples of it uses?
I searched Google with different search keys but could not really find any
example.

Your help will be greatly appreciated.

Thank you
 
A

Alex Fenton

Ruby said:
I am trying to learn wxruby and to that effect I played with the tutorial,
which is very limited.


Questions about wxRuby are more appropriate to the wxruby-users mailing
list:
http://rubyforge.org/mailman/listinfo/wxruby-users
OR WEB ACCESS:
http://www.ruby-forum.com/forum/36

If possible, show some example code with what you've tried and you will
find people happy to advise.

I am trying to draw a grid for a sudoku puzzle. I first tried using
GridSizer but then I did not know how to add each cell (button) to the 9x9
grid.


You create and add a button to a sizer with something like this:

sizer = Wx::GridSizer.new(9) # 9 column
button = Wx::Button.new(parent, :label => '3')
sizer.add(sudoku_button)

Then I thought that perhaps I should use GridBagSizer for flexibility or
something else.


Probably not GridBagSizer. It's offered b/c it's part of the wxWidgets
API, but there are almost always easier and simpler ways of doing the
same thing, IMHO.

I need to be able to change the caption of the button, which could have a
number from 1 to 9, dynamically.


No problem:

button.label = "4"

Which class should I use and where can I find examples of it uses?


You could use GridSizer + Buttons, as you have been. Simple, but it
might look a bit strange.

You could use Wx::Grid, a spreadsheet-style widget.

A bit more work, but probably the most attractive solution: you could
draw your own grid lines and numbers using a DC (Device Context).

You will find examples of using all of these by looking in the samples
distributed with the wxRuby gem / source. Look in samples/grid,
samples/bigdemo/wxSizer and samples/drawing for help.

a
 
R

Ruby Student

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

Alex, thank you for your quick and detailed reply.I will look at the samples
distributed with wx.

Thank you

Ruby Student
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top