=head1 NAME
Browser::Plugin - embed perl into a webbrowser using tcl/tk.
=head1 SYNOPSIS
=head1 DESCRIPTION
sorry...
=over 4
=cut
package Browser::Plugin::Tk;
use base Browser::Plugin;
use Tk ();
$VERSION = 0.01;
sub mainloop {
my $self = shift;
for(;;) {
if (Tk::MainWindow->Count) {
Tk::MainLoop;
} else {
$self->server_event;
}
}
}
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self;
}
sub window_new {
my $self = shift;
my $wi = $_[0];
$self->SUPER::window_new(@_);
print "BP1: @_\n";
return if $self->{win};
# "fix" idea by the famous Slaven Rezic of Pearl.
local $SIG{ABRT} = sub { die "ABRT" };
my $w = $self->{win} = eval {
new Tk::MainWindow (
-use => $wi->{id},
-borderwidth => 0,
-relief =>'sunken',
#-width => $wi->{width},
#-height => $wi->{height},
);
};
if ($w) {
$w->fileevent($self->server_fh, 'readable', [$self, 'server_event']);
$w->Label(-text => "Test")->pack;
print "mainwindow now is $w\n";
} else {
print "no window yet\n";
return ();
}
return $w;
}
sub window_delete {
my $self = shift;
$self->SUPER::window_delete(@_);
delete $self->{win};
}
sub DESTROY {
warn "DESTROY";
}
1;
=back
=head1 BUGS
=head1 SEE ALSO
L.
=head1 AUTHOR
Marc Lehmann
http://www.goof.com/pcg/marc/
=cut