Re: GTKCombo: autocomplete?

On Friday, May 21, 2004, at 12:46 AM, Daniel Kasak wrote:

    my $clientcombo = $bills_received->get_widget('SelectClient');
        # Set up autocompletion in GTKEntry
    $entrycompletion = Gtk2::EntryCompletion->new();

you forgot to tell the completion object which column of the model has the strings in it.

  $entrycompletion->set_text_column (0);

$bills_received->get_widget('SelectClient_Entry')- >set_completion($entrycompletion);

a complete, working example:

  use strict;
  use Gtk2 -init;
  my @strings = qw(one two three four five six seven eight nine);

  my $window = Gtk2::Dialog->new;
  $window->add_button ('gtk-close' => 'close');

  my $combo = Gtk2::Combo->new;
  $combo->set_popdown_strings (@strings);

  my $liststore = Gtk2::ListStore->new ('Glib::String');
  foreach (@strings) {
        $liststore->set ($liststore->append, 0, $_);

  my $completion = Gtk2::EntryCompletion->new;
  $completion->set_model ($liststore);
  $completion->set_text_column (0);
  $combo->entry->set_completion ($completion);

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

How come hair colors for women take an hour, but "wash out the gray" stuff for men only five minutes? This is so unfair!
    -- Elysse, complaining about commercials

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