Re: GTK2::TieScalar and DBI stuff



On Mon, 2004-05-03 at 19:33, Daniel Kasak wrote:
Hi all. I'm back.

I'm having trouble getting GTK2::TieScalar to work.
I have a sub that loads up data ( currently a single record ) into
@data:


You probably don't have the latest version of the TieScalar code.  Don't
know what's been posted, but here's the latest version attached.

With the code you seem to have, you'll have to tie the vars first.  The
act of TIEing in perl pretty much ignores the current value.  The
old(er) code didn't make any effort to set/restore when tied/untied. 
The newer code does.

You also don't want to be tieing multiple vars to the same widget
(unless you *really* are doing that on purpose), so I'd recommend you
have another object that is tied to the widgets, and you fill/restore
from the data array as you move through it.  I.e. moving to a new row
saves the "current" in the old row, and loads up the next row as the new
"current".  The tied vars should update all the widgets automatically.

psuedo-

my $scratch = new RowObj();

InitWidgets($tmp);

sub on_next_row {
  $data->[$curRow] = $scratch;   # save 
  ++$curRow;                     # next row
  $scratch = $data->[$curRow];   # set current, widgets are updated
}

This also gives you the opportunity to check if the user modified the
info, and prompt for updating, etc.

Regards,
Carl

Attachment: tiebind.tar.gz
Description: application/compressed-tar



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