Re: help with a script

I like it.
That was a helpful example.


I'm wading through it all by reading the tutorial by Stephen Wilhelm,
which is one the better tutorials, of any kind, I've seen on the net. But it only goes so far.

Paul R

Emil Perhinschi wrote:

Hi, Paul,

I'm a begginer, too, but the wizards are shy so I'll
have to speak.
Here is what i'll do. I don't guarantee that it's the
best way :)

sub pop_up_window {

   my $vbox;
   my $label;
   my $frame;

   ## Create the window # and make it a local variable

   my  $window = new Gtk::Window( "dialog" );

# and better change it's name, to avoid geting # confused later: your $window from &pop_up_window # was actually the main $window, if I am not # mistaken

                           sub {$window->destroy();});
# I guess that sub { Gtk->exit( 0 ); } terminates # the program

   $window->set_usize( 200, 100 );
   $window->border_width( 10 );

   $vbox = new Gtk::VBox( $false, 5 );

   $window->add( $vbox );

   $label = new Gtk::Label( "label in a popup " );
   $frame = new Gtk::Frame();
   $frame->add( $label );
   $vbox->pack_start( $frame, $false, $false, 0 );

   $button = new Gtk::Button( "Close" );
   $vbox->pack_start( $button, $true, $true, 0 );
   # XXXX
   #this sends the data
$button->signal_connect( "pressed", \&some_callback,
   #this destroys the dialog
                           sub {$window->destroy();});


sub some_callback
    my ($widget, $hungry_variable) = @_;

# and here you do something with # $hungry_variable ... # I don't think it made sense to return (0)
    # in &pop_up_window, because there was no
    # $global_hungry_var = &pop_up_window
    # in the main part of the script
# }

I am quite convinced that this is not the best way,
but it might work :)

best luck with Gtk-perl,

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