#!/usr/bin/perl -w
# 有點難解釋 ... 建議初學者不要看這個檔案

use vars qw($some_tk $tk_interpreter $tk_mainwindow);

BEGIN {

$some_tk = "mbvk" unless defined $some_tk;

if ($some_tk =~ /mbvk/i and eval 'do "Tcl/Tk.pm" ' ) {
print STDERR "using MBVK's Tcl::Tk for perl\n";
eval q(
    use Tcl::Tk qw(:perlTk);
    sub initTk {
	$tk_interpreter = Tcl::Tk->new(@_);
	return $tk_mainwindow = $tk_interpreter->mainwindow();
    }
    sub tk_messageBox { $tk_interpreter->call("tk_messageBox", @_); }
    sub tk_getOpenFile { $tk_interpreter->call("tk_getOpenFile", @_); }
    sub tk_chooseColor { $tk_interpreter->call("tk_chooseColor", @_); }
) } elsif (eval 'do "Tk.pm" ' ) {
if (not $some_tk =~ /nis/i) {
    print STDERR $some_tk =~ /mbvk/i ?
	"can't find MBVK's Tcl::Tk for perl\n" :
	"unknown Tk module '$some_tk' ignored\n";
}
print STDERR "using NIS's perl-Tk\n";
eval q(
    use Tk;
    sub initTk {
	return $tk_mainwindow = MainWindow->new(@_);
    }
    sub tk_messageBox { $tk_mainwindow->messageBox(@_); }
    sub tk_getOpenFile { $tk_mainwindow->getOpenFile(@_); }
    sub tk_chooseColor { $tk_mainwindow->chooseColor(@_); }
) } else {
    die 'can\'t find any Tk.pm';
}

} # BEGIN

1;

