Re: Notebook focus



On Tue, 2003-04-15 at 18:49, Chas Owens wrote:
else if there is a Gtk::VBox or Gtk::HBox that holds more than one Gtk::Text
then you need to attach data to the widget so you can find it again

my $text1 = Gtk::Text->new;
my $text2 = Gtk::Text->new;

$text1->{name} = "first"; #perlish way
$text2->{name} = "second"; #perlish way

.
#perlish way
for my $child ($notebook->get_current_page->child->children) {
        if (ref $child->{name} eq "second") {
                $child->insert(...);
        }
}


Okay, I can't make it work... I'm not experienced enough to program
complicated GUI! I wish users would be happy with command-line programs!

Here is the beginning of my code, where I create the pages.

$table = new Gtk::Table( 3, 6, $false );
$window->add( $table );

# Create a new notebook, place the position of the tabs
$notebook = new Gtk::Notebook();
$notebook->set_tab_pos( 'top' );
$table->attach_defaults( $notebook, 0, 6, 0, 1 );
$notebook->show();

# Let's append a bunch of pages to the notebook
for my $i ( 0..4 )
{

   $bufferl = $list_names[$i];
   $notebook_table = new Gtk::Table( 5, 6, $false );
   $notebook_table->show();

   # Let's create the "start" button
   $button_start = new Gtk::Button( "START" );

   $button_start->signal_connect( "clicked", sub { our $notebook; for my
$child ($notebook->get_current_page->child->children) { print
$child->{name}; } }, "START" );

   $notebook_table->attach( $button_start, 0, 1, 0, 1, 'fill', 'shrink',
0, 0 );
   $button_start->show();


I attach another table to the notebook_table and I attach the text
widget to it. I'm trying now to access the children (I gave them a
name), but I keep getting: 

Can't call method "child" without a package or object reference at
./hotline.perl line 67.

Is it a variable scope? I tried using "our notebook" to access it in
sub-routines, but unsuccessfully.

Many thanks in advance!

Regards,

-- 

Philippe Camus - Unix Administrator

In-Fusio http://www.in-fusio.com/
The mobile game connection 
Le Millenium 
12 Quai de Queyries 
33072 Bordeaux Cedex France 

Tel : +33 (0) 557 773 800 Ext.3846 
Fax : +33 (0) 556 400 548




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