Re: Embedded perl5 modules

2006-10-28 Thread Richard Hainsworth
Steffen: Sorry, Didnt see all correspondence immediately, and hence 
responded twice.


But here is an effort using Gtk2. It works.
Can anyone explain why the lines with .can, whilst the other syntaxes 
dont work?


file Gtk2Helper.pm
package Gtk2Helper;
use Gtk2;
sub new_Window {
   return Gtk2::Window-new(@_);
};
sub new_Button {
   return Gtk2::Button-new(@_);
};
1;
end file
file Gtk2_test.p6
use perl5:Gtk2;
use perl5:Gtk2Helper;

Gtk2.init;

#This does not work
#my $window = Gtk2Helper.new_Window('toplevel');
#This does not work
#my $window = Gtk2Helper::new_Window('toplevel');

# The following works
my nw := Gtk2Helper.can('new_Window');
my $window = nw('toplevel');

my nb := Gtk2Helper.can('new_Button');
my $button = nb('Quit this dull mortal world');
$button.signal_connect('clicked', sub { Gtk2.main_quit });
$window.add($button);
$window.show_all;
Gtk2.main;

Richard

Steffen Schwigon wrote:

Richard Hainsworth [EMAIL PROTECTED] writes:
  

Tried
use perl5:Wx::SimpleApp;
but the compiler complained it could not find SimpleApp.pm



Did you see my other suggestion with an intermediate WxHelper
(http://www.nntp.perl.org/group/perl.perl6.users/546)?

It also doesn't really work but at least it gets you a step
further. Try it and maybe you have the next idea as you maybe 
know Wx better than I do. 


Steffen
  


Re: Embedded perl5 modules

2006-10-25 Thread Steffen Schwigon
Richard Hainsworth [EMAIL PROTECTED] writes:
 Tried
 use perl5:Wx::SimpleApp;
 but the compiler complained it could not find SimpleApp.pm

Did you see my other suggestion with an intermediate WxHelper
(http://www.nntp.perl.org/group/perl.perl6.users/546)?

It also doesn't really work but at least it gets you a step
further. Try it and maybe you have the next idea as you maybe 
know Wx better than I do. 

Steffen
-- 
Steffen Schwigon [EMAIL PROTECTED]
Dresden Perl Mongers http://dresden-pm.org/
Deutscher Perl-Workshop http://www.perl-workshop.de/



Re: Embedded perl5 modules

2006-10-24 Thread Richard Hainsworth

Tried
use perl5:Wx::SimpleApp;
but the compiler complained it could not find SimpleApp.pm

GUI packages, which are wrappers around C classes, seem to use all the 
techniques of perl5. I dont understand them to find out what is going 
on, or to isolate what the error so as to put it into a test.


In general, it seems to me that for there to be full use of perl5 
modules in perl6, the useage in perl6 should be the same as in perl5 
(bar the minor changes in syntax). Thus if

use Wx;
is sufficient in perl5 for Wx::SimpleApp to be a recognised namespace in 
the program and for the compiler to know where to go to get 
Wx::SimpleApp-new, then in perl6 the same should be true, viz.,

use perl5:Wx;
Wx::SimpleApp.new

Regards,

Richard

Steffen Schwigon wrote:

Richard Hainsworth [EMAIL PROTECTED] writes:
  

use perl5:Wx;
my $app = Wx::SimpleApp.new;
my $frame=Wx::Frame.new(undef, -1, 'Hello world!');
$frame.Show;
$app.MainLoop;

The following is the result:
$pugs wxtest.p6
*** No compatible subroutine found: Wx::SimpleApp
   at wxtest.p6 line 2, column 1-28

Is the perl6 wrong?

I have also tested
use perl5:Wx SimpleApp;



Maybe an additional

 use perl5:Wx::SimpleApp;

? I'm just guessing...

Steffen
  


Re: Embedded perl5 modules

2006-10-23 Thread Steffen Schwigon
Richard Hainsworth [EMAIL PROTECTED] writes:
Steffen said:
Maybe an additional
 use perl5:Wx::SimpleApp;
 Tried it. Doesnt work. 

In the meantime I tried my guess and also had to learn that. See also
my experiments in my other answer.


 *However, surely a perl6 program using a perl5 module should not
 require a more complex calling structure/approach than the
 equivalent perl5 module.

 Hence if
 use Wx;
 is sufficient for a perl5 program to find Wx::SimpleApp and Wx::Frame
 packages (namespaces), then
 use perl5:Wx;
 should be sufficient for a perl6 program.

 No??

Of course you are right ... in a finished perfect world. But currently
we have not yet arrived. Therefore I deduced my guess from the known
issues with using Perl5-from-Perl6 regarding export/import.

And when you write use Wx; and get all other packages en passant,
then Wx does some of that Exporter stuff. So Wx is a maybe a rather
hard test for Perl5 integration.

Did you have success using other Perl5 modules?

I'm not sure about your target. If you want to learn Perl5
integration, maybe try something easier first.

If you explicitly just need it with Wx, then maybe you still have to
wait some time or find someone from the Pugs coders who might help.

Maybe we should write a little test in the Pugs repository for that
behaviour. Without Wx but with that indirect package export/import
that Wx does. I'm just not sure where it belongs. Maybe near
t/perl5/import.t -- go for it, if you dare. :-)


Steffen
-- 
Steffen Schwigon [EMAIL PROTECTED]
Dresden Perl Mongers http://dresden-pm.org/



Re: Embedded perl5 modules

2006-10-22 Thread Richard Hainsworth

Steffen said:
Maybe an additional

 use perl5:Wx::SimpleApp;

 ? I'm just guessing...

 Steffen
--
Steffen Schwigon schwi... 
http://groups.google.com/groups/unlock?msg=5db1a47bed78a20d_done=/group/perl.perl6.users/browse_frm/thread/4c85d7fedf76dd11/6ec62de446f6ea38%3F@webit.de 


Dresden Perl Mongers http://dresden-pm.org/

Tried it. Doesnt work. Just gives the following error:
*Error eval perl5: require Wx::SimpleApp; 'Wx::SimpleApp'
*** Can't locate Wx/SimpleApp.pm in @INC (@INC contains: /etc/perl rest 
snipped


*However, surely a perl6 program using a perl5 module should not require 
a more complex calling structure/approach than the equivalent perl5 module.


Hence if
use Wx;
is sufficient for a perl5 program to find Wx::SimpleApp and Wx::Frame 
packages (namespaces), then

use perl5:Wx;
should be sufficient for a perl6 program.

No??

Richard


Embedded perl5 modules

2006-10-20 Thread Richard Hainsworth
Upgraded to pugs 6.13 after seeing comprehensive support for 
interoperability with Perl 5 modules.


I want to test gui modules and I am trying the Gtk2 and Wx modules.

The following program works under perl5:
use strict;
use Wx;
my $app = Wx::SimpleApp-new;
my $frame=Wx::Frame-new(undef, -1, 'Hello world!');
$frame-Show;
$app-MainLoop;

The program places a window on the desktop with Hello world! as the title.

I naively modified to perl6 (wxtest.p6) as follows:
use perl5:Wx;
my $app = Wx::SimpleApp.new;
my $frame=Wx::Frame.new(undef, -1, 'Hello world!');
$frame.Show;
$app.MainLoop;

The following is the result:
$pugs wxtest.p6
*** No compatible subroutine found: Wx::SimpleApp
   at wxtest.p6 line 2, column 1-28

Is the perl6 wrong?

I have also tested
use perl5:Wx SimpleApp;

Richard


Re: Embedded perl5 modules

2006-10-20 Thread Steffen Schwigon
Richard Hainsworth [EMAIL PROTECTED] writes:
 use perl5:Wx;
 my $app = Wx::SimpleApp.new;
 my $frame=Wx::Frame.new(undef, -1, 'Hello world!');
 $frame.Show;
 $app.MainLoop;

 The following is the result:
 $pugs wxtest.p6
 *** No compatible subroutine found: Wx::SimpleApp
at wxtest.p6 line 2, column 1-28

 Is the perl6 wrong?

 I have also tested
 use perl5:Wx SimpleApp;

Maybe an additional

 use perl5:Wx::SimpleApp;

? I'm just guessing...

Steffen
-- 
Steffen Schwigon [EMAIL PROTECTED]
Dresden Perl Mongers http://dresden-pm.org/