Here's the code...
#!usr/bin/perl
use strict;
use Tk;
my $main = new MainWindow(-title => 'File Box');
$main->geometry('400x300');
my $menubar = $main->Menu(-type => 'menubar');
$main->configure(-menu => $menubar);
my $f = $menubar->cascade( -label => '~File', -tearoff => 0);
$f->command(-label => 'Open ...', -command => &fileDialog($main));
MainLoop;
sub fileDialog {
my $w = $_[0];
my $types;
my $file;
my @types =
(["Text Files", [qw/.txt/]],
);
$file = $w->getOpenFile(-filetypes => \@types);
}
ok,
the problem is that the FileBox pops when the program is loaded and not when (as it should be...) i do: File->Open
besides that, when i close the file box the script hangs and the only thing that still works is the menubar...
can someone help me with this?
thanks...
#!usr/bin/perl
use strict;
use Tk;
my $main = new MainWindow(-title => 'File Box');
$main->geometry('400x300');
my $menubar = $main->Menu(-type => 'menubar');
$main->configure(-menu => $menubar);
my $f = $menubar->cascade( -label => '~File', -tearoff => 0);
$f->command(-label => 'Open ...', -command => &fileDialog($main));
MainLoop;
sub fileDialog {
my $w = $_[0];
my $types;
my $file;
my @types =
(["Text Files", [qw/.txt/]],
);
$file = $w->getOpenFile(-filetypes => \@types);
}
ok,
the problem is that the FileBox pops when the program is loaded and not when (as it should be...) i do: File->Open
besides that, when i close the file box the script hangs and the only thing that still works is the menubar...
can someone help me with this?
thanks...