$Tcl::Tk::VTEMP = <<'EOWIDG'; package Tcl::Tk::Widget::[[widget-repl]]; use vars qw/@ISA/; @ISA = qw(Tcl::Tk::Widget); sub DESTROY {} # do not let AUTOLOAD catch this method sub AUTOLOAD { print STDERR "<<@_>>\n" if $Tcl::Tk::DEBUG > 2; $Tcl::Tk::Widget::AUTOLOAD = $Tcl::Tk::Widget::[[widget-repl]]::AUTOLOAD; return &Tcl::Tk::Widget::AUTOLOAD; } 1; print STDERR "<>\n" if $Tcl::Tk::DEBUG > 2; EOWIDG #### # here we create Widget package, used for both standard cases like # 'Button', 'Label', and so on, and for all other widgets like Baloon # TODO : document better and provide as public way of doing things? my %created_w_packages; # (may be look in global stash %:: ?) sub create_widget_package { my $widgetname = shift; _DEBUG(2, "AUTOCREATE widget $widgetname (@_)\n") if DEBUG; unless (exists $created_w_packages{$widgetname}) { _DEBUG(1, "c-PACKAGE $widgetname (@_)\n") if DEBUG; $created_w_packages{$widgetname} = {}; die "not allowed widg name $widgetname" unless $widgetname=~/^\w+$/; # here we create Widget package my $package = $Tcl::Tk::VTEMP; $package =~ s/\[\[widget-repl\]\]/$widgetname/g; eval "$package"; die $@ if $@; # Add this widget class to ptk_w_names so the AUTOLOADer properly # identifies it for creating class methods $widgetname = quotemeta($widgetname); # to prevent chars corrupting regexp $ptk_w_names .= "|$widgetname"; } }