The .can workaround doesnt seem to work for more complex modules.

Here is a working perl5 program that puts up a message with two buttons.

use strict;
use Gtk2 -init;
use Gtk2::Ex::Dialogs(destroy_with_parent=>-1, modal=>-1, no_separator => 0);
my $window = Gtk2::Window->new('toplevel');
Gtk2::Ex::Dialogs->set_parent_window( $window );
my $r = Gtk2::Ex::Dialogs::Question->ask( "Is Perl only hackers glue?");
if ($r) {print "yes\n";} else {print "no\n";};

Here is an attempt to do the same in perl6

use v6;
use perl5:Gtk2 -init;
say "called Gtk3 init";
my $window = initialise();
say "window initialised";
use perl5:Gtk2::Ex::Dialogs(destroy_with_parent=>-1, modal=>-1, no_separator => 0);
our &gsetparent := Gtk2::Ex::Dialogs.can('set_parent_window');
say "Now trying to use the window";
gsetparent( $window );
our &ask := Gtk2::Ex::Dialogs::Question.can('ask');
my $r = ask( "Is Perl only hackers glue?");
if ($r) {say "yes";} else {say "no";};

sub initialise () {
# I took this eval(uation) of perl5 by pugs from one of the examples in the pugs distribution
   eval (q!
           my $win = Gtk2::Window->new('toplevel');
           $win;
               !,:lang<perl5>);
};


Here is the output
$ pugs ./gtk2_test.p6
called Gtk3 init
window initialised
Now trying to use the window
Undefined subroutine &main:: called.

I tried a variety of coding techniques. None seems to work.
eg.,
our &gwin := Gtk2::Window.can('new');
our &gwin := Gtk2.can('Window->new');
our &gwin := Gtk2.can('Window.new');

The problem seems to be that Gtk2::Window does not exist as a separate module, viz., there is no Window.pm in the Gtk2 directory space.

Any ideas?

Reply via email to