Re: Easy way to create a set of list/entry widgets?

On Tue, Jan 04, 2005 at 22:18:30 -0700, Tyler Hepworth wrote:
I am trying to create a set of list/entry widgets, but don't desire to
type out the code for each widget, so I tried the following:

my ($name_label, $name_entry,
    $area_label, $area_entry,
    $soil_label, $soil_entry,
    $description_label, $description_entry,
    $comments_label, $comments_entry
my @values = (["Name: ",$name_label, $name_entry],
    ["Area: ",$area_label, $area_entry],
    ["Soil Type: ",$soil_label, $soil_entry],
    ["Description: ", $description_label, $description_entry],
    ["Comments: ",$comments_label, $comments_entry]

[...] all necessary vboxes, packing, etc go here [...]

foreach my $values (@values) {
    \$values->[1] = Gtk2::Label->new ($values->[0]);
    \$values->[2] = Gtk2::Entry->new;

my $row;
foreach my $values (@values) {
    $table->attach_defaults ($values->[1], 0,1, $row, $row + 1);
    $table->attach_defaults ($values->[2], 1,2, $row, ++$row);

When I run the program, I get the error: "Can't modify single ref
constructor in scalar assignment.

Refer to the perlreftut and perlref man/perldoc pages.

Basicaly, you put values where you obviously intended to put references
and than you are taking a reference instead of dereferencing (that's
what causes the error). \ is the REFERENCE operator and ${} is scalar

Can someone either shed some light on the error message and how to fix
it (if possible) or point me in another direction for easily creating
an otherwise cumbersome amount of code for label/entry widgets?

Your problem has nothing to do with Gtk.

                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature

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