in reply to Open another Tk window

When you say, "call another program" you need to be very careful when running a gui like Tk. Why? Because you will run into the problem of "blocking the gui". If you call "system some_other_perl_script", the tk gui will become unresponsive, while the cpu services the call, and runs the other script. So what you want to do is "fork and exec" and return the results in another window.

There is a very good module for doing this, called Tk::ExecuteCommand. Here is a basic example. You can do alot with this module, like pack it into different toplevel windows, instead of the mainwindow. A second example below does that. You can also change the appearance of the widget, by accessing it's "Advertised Subwidgets".

#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::ExecuteCommand; my $mw = MainWindow->new; my $ec_dir = $mw->ExecuteCommand( -command => 'dir; sleep 10; dir;', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute dir ', )->pack; my $ec_date = $mw->ExecuteCommand( -command => 'date; sleep 10; date;', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute date ', )->pack; my $dir_but = $mw->Button( -text => 'Execute dir', -background => 'hotpink', -command => sub{ $ec_dir->execute_command })->pack; my $date_but = $mw->Button( -text => 'Execute date', -background => 'lightgreen', -command => sub{ $ec_date->execute_command })->pack; MainLoop;

For a separate toplevel:

#!/usr/bin/perl -w use Tk; use Tk::ExecuteCommand; use Tk::widgets qw/LabEntry/; use strict; my $mw = MainWindow->new; my $top = $mw->Toplevel; $top->withdraw; my $ec = $top->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'date; sleep 10; date'); my $button = $mw->Button(-text =>'Do_it', -background =>'hotpink', -command => sub{ $top->deiconify; $top->raise; $ec->execute_command; $top->withdraw}, )->pack; MainLoop;

I'm not really a human, but I play one on earth. flash japh