#!/usr/bin/perl --
use strict;
use warnings;
Main( @ARGV );
exit( 0 );
sub Main {
Fudge();
Fudge();
}
sub Fudge {
use Tcl::Tk;
my $int = new Tcl::Tk;
my $mw = $int->mainwindow;
my $lab = $mw->Label(-text => "Hello world")->pack;
my $btn = $mw->Button(-text => "test", -command => sub {
$lab->configure(-text=>"[". $lab->cget('-text')."]");
})->pack;
$int->MainLoop;
}
Why this works? Because each $int Tcl::Tk is a new Tcl interpreter
Why the same doesn't work with Tkx? Because Tkx creates a single Tcl interpreter, and when it ends, that's it, it ends
You can patch Tkx.pm, its pure-perl, but this is a bug in Tkx |