$combo->list = ( $combo->list, "append1",...



Its a little long I'm afraid - check out the add_user() function below!


I've also attached the file but I am unsure whether attachments are 
allowed!!

Thanks

----------- start --------------
#!/usr/bin/perl -w

use Gtk;
use strict;

set_locale Gtk;
init Gtk;

my $false = 0;
my $true = 1;


my $window = new Gtk::Window( "toplevel" );
my $vbox = new Gtk::VBox( $false, 5 );
my $entry = new Gtk::Entry(30);
my $combo = new Gtk::Combo();

$window->set_position( 'center' );
$window->set_title( "test" );
$window->signal_connect( "destroy", sub { Gtk->exit( 0 ); } );
$window->border_width( 10 );
$window->set_policy(0,0,0); #(allow_shrink,allow_grow,auto_shrink)
$window->realize();

$vbox->border_width( 5 );
$combo->set_popdown_strings( "1","2","3" );
$vbox->pack_start( $combo, 0, 0, 0 );

my $button_remove = new Gtk::Button();
my $button_hbox = new Gtk::HBox( $false, 5 );
my $label = new Gtk::Label( "Remove User" );
$button_hbox->pack_start( $label, $true, $false, $false );
$button_remove->add( $button_hbox );
$button_remove->signal_connect( "clicked", \&rem_eng, $combo);
$vbox->add( $button_remove );
$label = new Gtk::Label( "\n" );
$vbox->add( $label );

my $button_add = new Gtk::Button();
$label = new Gtk::Label( "Add user" );
$button_hbox = new Gtk::HBox( $false, 5 );
$button_hbox->pack_start( $label, $true, $false, $false );
$button_add->add( $button_hbox );
$button_add->signal_connect( "clicked", \&add_eng, $entry, $combo );

$vbox->pack_start( $entry, $true, $true, 0 );
$vbox->add( $button_add );

$window->add( $vbox );
$window->show_all();

sub add_eng
{
    my ( $widget, $entry, $combo ) = @_;
    my $entry_text = $entry->get_text();
    print "Entry contents: $entry_text\n";
    $combo->list->append_items($entry_text);
}

sub rem_eng
{
    my ( $widget, $combo ) = @_;
    my $combo_text = $combo->entry->get_text();
    print "Combo contents: $combo_text\n";
}

main Gtk;
exit( 0 );
------------ end --------------

Regards

On Wed, 2003-02-26 at 17:51, Scott Smith wrote:
Can you put together a tiny demo of the problem and include it in your
email?

On Wed, 2003-02-26 at 12:16, Andy Ford wrote:
Thanks for your response Scott

I tried what you said but I now get ..

item cannot be undef at ... etc etc

!!

Thanks

On Wed, 2003-02-26 at 17:13, Scott Smith wrote:
Try:
$combo->list->append_items("HI");

Also, in general you do not do:
$obj->some_property = $value

Instead, you do:
$obj->some_property($value);

The "property" is actually an object method subroutine which sets the
value you specify, and does any internal operations necessary because of
your new setting.


On Wed, 2003-02-26 at 11:43, Andy Ford wrote:
I am trying to use the combo->list = ($combo->list, "new entry") to
append a 'new entry' to a combo box.

When I use it as thus....

sub func
{
   my ( $widget, $combo ) = @_;
   combo->list = ($combo->list, "HI");
}

I get the following error ...

Can't modify non-lvalue subroutine call at .... etc etc

How do I append text to a combo box!?

Thanks


Andy Ford

_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
-- 
Scott Smith <ssmith watson wustl edu>
-- 
Scott Smith <ssmith watson wustl edu>
-- 
Andy Ford 




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