Hi Aldric
Aldric Giacomoni wrote:> Hey guys. First post, and I have a project which is ambitious (to me
> anyway, since this is my first foray ever in GUI).
> I want to dynamically create (from 2 arrays for instance) a table with
> rows and columns, and each ''cell'' would behave like a
checkbox, sending
> a query to a database tailored after the row/column in which it is (a
> very simple query).
Welcome to wxRuby which, happily, has a widget that I think will be very
well suited to your project. It''s called Wx::Grid, and the
documentation
is here:
http://wxruby.rubyforge.org/doc/grid.html
Note that there is one missing section we recently noticed in this doc,
which describes some of the events generated by grid. Have a look also at:
http://docs.wxwidgets.org/stable/wx_wxgrid.html
There are two quite comprehensive grid samples that came with your
wxruby installation, in <libdir>/samples/grid/. You could study these as
an intermediary project.
Briefly, on some of the things you want to do:
- to display cells with check-box like appearance, use
Wx::GridCellBoolRenderer and Wx::GridCellBoolEditor classes. If you find
you don''t like the default way these work, you can also completely
customise how cells are displayed using your own subclass of
Wx::GridCellRenderer.
- to handle an action when a cell is checked or unchecked, set up an
event handler on evt_grid_cell_change.
- if you already have the code that interacts with the database, an
efficient way to link this to the GUI display can be to use
GridTableBase. I won''t go into detail, but have a look at the sample -
if you''re used to model/view separation this works nicely.
hth
alex