use Tcl::Tk; my $mw = MainWindow; my $int = $mw->interp; $int->CreateCommand("MySubroutine", \&MySubroutine); $int->Eval(); sub MySubroutine{ ... } Mainloop;