MoshiachNow
IS-IT--Management
Hi,
Trying ro get a user to browse for the target dir.
Have taken this code form a widget demo,but it does not seem to work well for me.
I know that "WidgetDemo" is should not be there - but what should ?
my $mw = new MainWindow; #define the main window
$mw->configure(-title=>"rehost.exe Ver $VERSION on $computer" # Main Window
$mw->geometry('+380+10');
use vars qw/$TOP/;
$TOP = $mw->WidgetDemo
(
-name => 'Choose dir',
-text => "Enter a directory name in the entry box or click on the \"Browse\" buttons to select a directory name using the directory selection dialog.",
-title => 'Choose Directory Demonstration',
-iconname => 'choosedir',
);
$f = $TOP->Frame;
$lab = $f->Label(-text => "Select a directory to open: ",
-anchor => 'e');
$ent = $f->Entry(-width => 20);
$but = $f->Button(-text => "Browse ...",
-command => sub { dirDialog($TOP, $ent)});
$lab->pack(-side => 'left');
$ent->pack(-side => 'left',-expand => 'yes', -fill => 'x');
$but->pack(-side => 'left');
$f->pack(-fill => 'x', -padx => '1c', -pady => 3);
sub dirDialog {
my $w = shift;
my $ent = shift;
my $dir;
$dir = $w->chooseDirectory;
if (defined $dir and $dir ne '') {
$ent->delete(0, 'end');
$ent->insert(0, $dir);
$ent->xview('end');
}
}
MainLoop;
Long live king Moshiach !
Trying ro get a user to browse for the target dir.
Have taken this code form a widget demo,but it does not seem to work well for me.
I know that "WidgetDemo" is should not be there - but what should ?
my $mw = new MainWindow; #define the main window
$mw->configure(-title=>"rehost.exe Ver $VERSION on $computer" # Main Window
$mw->geometry('+380+10');
use vars qw/$TOP/;
$TOP = $mw->WidgetDemo
(
-name => 'Choose dir',
-text => "Enter a directory name in the entry box or click on the \"Browse\" buttons to select a directory name using the directory selection dialog.",
-title => 'Choose Directory Demonstration',
-iconname => 'choosedir',
);
$f = $TOP->Frame;
$lab = $f->Label(-text => "Select a directory to open: ",
-anchor => 'e');
$ent = $f->Entry(-width => 20);
$but = $f->Button(-text => "Browse ...",
-command => sub { dirDialog($TOP, $ent)});
$lab->pack(-side => 'left');
$ent->pack(-side => 'left',-expand => 'yes', -fill => 'x');
$but->pack(-side => 'left');
$f->pack(-fill => 'x', -padx => '1c', -pady => 3);
sub dirDialog {
my $w = shift;
my $ent = shift;
my $dir;
$dir = $w->chooseDirectory;
if (defined $dir and $dir ne '') {
$ent->delete(0, 'end');
$ent->insert(0, $dir);
$ent->xview('end');
}
}
MainLoop;
Long live king Moshiach !