short demo program follows. Window will look like any other Windows application "file open", there is icon shortcut for Desktop, recently used, etc. All the drives on system are shown. You can filter by extension.I just put a .txt and .log button to show you how. It remembers where you were last time, so opening this window goes conveniently to last directory that you were in. I haven't used it for selecting multiple things but I'm sure it can do that too.
#!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new; $mw->geometry("400x400+0+0"); my $menu_f = $mw->Frame()->pack(-side=>'top',-fill=>'x'); my $menu_file = $menu_f->Menubutton (-text=>'File',-tearoff=>'false') ->pack(-side=>'left'); $menu_file->command(-label=>'Open', -command=> \&get_file); #other menu buttons shown here as examples ... #$menu_file->command(-label=>'Save', # -command=> \&save_log); #$menu_file->command(-label=>'Close', # -command=> \&close_log); #$menu_file->command(-label=>'Exit',-command=>\&exit_msg); sub get_file { my @types = (["Log files", [qw/.txt .log/]], ["All files", '*'], ); my $filepath = $mw->getOpenFile(-filetypes => \@types) or return(); print "$filepath selected\n"; return($filepath); } MainLoop;
In reply to Re: Directory and file selection with PERL/Tk
by Marshall
in thread Directory and file selection with PERL/Tk
by chanklaus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |