Re: Database interaction

Zach Bean wrote:

Quoting muppet <scott asofyet org>:

Of course, no such widget exists..
that sounds like a great opportunity for someone seeking gtk2-perl fame
and glory...  :-)

As it turns out, I've already written something like this for a database
project I'm working on.

It takes a "client" object that defines at least 3 methods:
 * user_col_count() -- returns the number of columns to be dealt with.
 * user_cols() -- returns a reference to an array of hashrefs describing
the columns.
 * user_col_value($col_name, $row_id) --  returns the value for $col_id
in row $row_id

The hashrefs returned by user_cols() need to have the following keys:
 * name -- the column name in the database.
 * type -- the type of the column, one of: integer, boolean, float, and
string.  This is used to display the right sort of editing widget (spin
button, check button, spin button, and entry, respectively).
 * label -- the label that should be displayed with the widget.

The widget inherits from Gtk2::Table, and creates a table with 4 columns
and as many rows as necessary.  The widgets are displayed with labels in
columns 1 and 3, and data widgets in columns 2 and 4.

Like I said, I've written this for a project I'm currently working on, so
it's not complete (ie, it can't store information back to the database
;o) but I'm still working on it.

Is this something that people would like to have in Gtk2-Perl?  If so, I'd
certainly be happy to maintain it.  I'm also not sure if it'd be useful
for the OP's problem, but it sounds like it's at least part of the way to
a solution :o)  I haven't attached it here, because I wasn't sure if that
was appropriate.  Let me know if you'd like to take a look!

I've finished a 'just-barely-limping-along' object to handle DB interaction with a glade-generated form.
It does querying, record navigation, applying updates and inserting records.

I was about to start on a similar object for a SimpleList version when I remembered this post where you said you were doing the same ( but using a custom TreeModel ). Want to share code ? :) I'll post what I've got to you / the list if there is interest.

Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
Title: CanIt Vote for ID 53169

The following links have been placed here by the NUS Consulting internal spam filter and are for use by NUS Consulting staff only.
Please ingore these links.
Not spam
Forget previous vote

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]