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?
Err, the .can workaround is a way to get past missing sub
exports. Methods are never exported. Why are you using the
workaround for sub exports on methods.
> 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";};
Should be simply:
use perl5:Gtk2 '-init';
use perl5:Gtk2::Ex::Dialogs :destroy_with_parent( -1 ) :modal( -1 ) :!no_separator;
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?" );
say $r ?? 'yes' !! 'no';
Regards,
--
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;
However, I am using pugs from the debian package and not directly from
the repository. So perhaps, the problem is I am not using the latest
version of pugs.
Regards,
Richard
That version is rather old in our universe :)
--
korajn salutojn,
juerd waalboer: perl hacker <ju...@juerd.nl> <http://juerd.nl/sig>
convolution: ict solutions and consultancy <sa...@convolution.nl>
Note my translation was purely based on what I picked up, and
completely untested. Debug as needed to fix it.
Regards,
--
Aristotle Pagaltzis // <http://plasmasturm.org/>