Re: Database interaction



Ugh, can't resist....


If I had to do what you're talking about, Here's what I'd do:

Assume I have a nice encapsulation of a table row, something like:

my $rowMgr = DBRow->new(TABLE => "tableName", 
                        FIELDS => ("FIELD_1", "FIELD_2"));

assume DBRow is blessed hash, which fills member DATA => {} holding row
values indexed by FIELDS name

And assuming you've used Glade to create your form windows, with the
widgets named the same as the field names

sub ConnectToForm {
  my $formName = shift;
  my $rowMgr = shift;
  my $fields = $rowMgr->{FIELDS};

  use Gtk2 -init;
  use Gtk2::GladeXML;
  use Gtk2::TieScalar;

  $glade = Gtk2::GladeXML->new("$formName.glade", $formName);

  foreach my $f (@$fields) {
    Gtk2::TieScalar->create(\$rowMgr->{DATA}->{$f}, $glade->get_widget($f));
  }
}

Now you have the field entries connected to your Entry widgets.  Then
just connect your control buttons (forward, back, save, update, delete,
etc.) to your DBRow object, and let it fill in the DATA hash with the
row info.  How you do that is up to you.  The TieScalar object will keep
the field updated in the widget.

BTW, TieScalar doesn't exist in Gtk2 release as of yet.  But the tarball
should be locatable on the list archives.

On Tue, 2004-04-27 at 19:23, Daniel Kasak wrote:
A. Pagaltzis wrote: 
* Daniel Kasak <dkasak nusconsulting com au> [2004-04-27 04:33]:
  
A tabular view would also be nice, but would be a 2nd priority for me.
    





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