Hi everyone, I am trying to implement a class which takes in configuration information from the user via a gui and performs various tasks based on the methods called by the user.
The following is a working code snippet: ------------ package Test; use strict; use Win32::GUI; sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {CNF => {}}; # my %cnf = @_; # for (keys %cnf) # { # $self->{lc($_)} = $cnf{$_}; # } bless ($self, $class); $self->configure; return $self; } sub configure { my $self = shift; ################################################# #Display the GUI with relevant autofilled entries ################################################# my $font = Win32::GUI::Font->new( -name => "Courier New", -size => 16, ); my $justify = 72; $self->{'CNF'}->{'Window'} = new Win32::GUI::Window( -name => "Window", -title => "Welcome to Test!", -left => 50, -top => 50, -width => 810, -height => 600, -font => $font, ); $self->{'CNF'}->{'Window'}->{-dialogui} =1; $self->{'CNF'}->{'Window'}->AddTextfield( -name => "Username", -left => 20, -top => 10, -width => 200, -height => 20, -text => 'test', -prompt => "Please enter the username"." "x($justify-length("Please enter the username")), -tabstop => 1, ); $self->{'CNF'}->{'Window'}->AddButton( -name => "Start", -align => "center", -height => 30, -width => 60, -text => "Start", -top => 510, -left => 360, -tabstop => 1, #-default => 1, #-ok => 1, ); $self->{'CNF'}->{'Window'}->{'Start'}->Show; $self->{'CNF'}->{'Window'}->{'Start'}->SetFocus(); $self->{'CNF'}->{'Window'}->Show; Win32::GUI::Dialog(); } #sub Start_Click #{ # print &Test::self->{'CNF'}->{'Window'}->{'Username'}->Text,"\n","Test","\n"; ## Win32::MsgBox( "Test", ,0+MB_ICONINFORMATION, "Cmd line"); ## exit(); # return 1; #} # #sub Window_Terminate { # return -1; #} package main; my $test = Test->new(); sub Start_Click { # print &Test::self->{'CNF'}->{'Window'}->{'Username'}->Text,"\n","Test","\n"; # Win32::MsgBox( "Test", ,0+MB_ICONINFORMATION, "Cmd line"); # exit(); return -1; } sub Window_Terminate { return -1; } print $test->{'CNF'}->{'Window'}->{'Username'}->Text,"\n"; --------------- In the package main, when I create a new object using Test->new(); the GUI defined in package Test shows up. When the user clicks Start I would like the object created and returned to the package main. For this to happen the only way it works is if sub Start_Click {} is defined in package main. Is it possible to define this sub Start_Click in package Test and get it working so that the entire GUI code is hidden from package main? I did a search of the archives and i found something called NEM at http://sourceforge.net/mailarchive/message.php?msg_id=11271102 and at http://sourceforge.net/mailarchive/message.php?msg_id=12559985. Is there some documentation or a working example of using the NEM? I am fairly new to objects too, I hope I am not making any obvious gotchas... Thanks, Emmanuel -- Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko! Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner