mikep has asked for the wisdom of the Perl Monks concerning the following question:

Hello, i am trying to use the FBox widget in perl's Tk module. the platform is cygwin running on window's XP. i'm new to Tk, but not to perl. i'm trying the get the -multiple option to work. 'multiple' is supposed to allow multiple files to be selected by FBox. i doesn't work for me. i also tried calling getOpenFile() directly with -multiple and that didn't work either (i believe FBox is a front end to getOpenFile()).

FBox wants option=>value pairs, and the docs i saw specify that -multiple doesn't need a value, so that's confusing, but i tried specifing -multiple a few different ways and none worked. the program executed, but i was not allowed to select multiple files.

i can provide more details if anyone is interested, but for now the basic question is: does this feature actually work? has anyone ever succussfully used it on any platform? ever successfully used it under cygwin on XP. i've scoured the net and couldn't find anything saying it shouldn't work.

thanks in advance. i'm really hoping it's pilot error.

Replies are listed 'Best First'.
Re: FBox, getOpenFile, -multiple
by zentara (Cardinal) on Jan 25, 2007 at 20:40 UTC
    hoping for pilot error, but is confronted with bad airframe design

    I avoid win32 like the plaque, but have seen complaints about filedialog on xp being buggy. See groups.google search

    or you may ask this on comp.lang.perl.tk where more win32 tk users may see you question. Or you could post a small snippet demonstrating the problem, and we can report what we see on other platforms.


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
      zentara - thanks for the reply. if you avoid win32, is there something else you use for gui on windows? i'm new to perl on windows and need a gui. i chose cygwin's perl 'cause i'm lazy and more familiar with unix. i know about activestate but haven't work with it at all. does activestate have some gui interface? i was hoping this would be a quick and easy project... should this question be in the chatterbox? thanks.
        ActiveStatePerl is the easiest way to go, and Tk is automatically included in ActiveStatePerl. The one drawback to ActiveState is the need to get precompiled ppms for the various binary modules, it's very hard to compile them yourself. If you are looking for something that will allow you to compile your binary modules, see Are you using Vanilla/Strawberry Perl? Tell me about it!

        Most people have little trouble with running Tk on ActiveState ( there are the minor incompatibilities).

        You can also avoid using getopenfile on windows with something like the following:

        #!/usr/bin/perl use strict; use Tk; require Tk::DirTree; require Tk::Adjuster; require Tk::TList; # The initial directory my $initial_dir = '/'; # The main window... my $main = new MainWindow( -title => 'Explorer)' ); # A frame for the tree, adjuster and tlist my $tree_adj_tablist = $main->Frame(); $tree_adj_tablist->pack( -expand => 'yes', -fill => 'both', -side => 'top' ); # A scrolled directory tree my $tree = $tree_adj_tablist->Scrolled( 'DirTree', -width => 35, -height => 25, -scrollbars => 'osoe', -background => 'White', -selectmode => 'single', -selectbackground => 'DarkBlue', -selectforeground => 'White', -showhidden => 1, -directory => $initial_dir ); $tree->pack( -expand => 'yes', -fill => 'both', -padx => 2, -pady => 2, -side => 'left' ); # An adjuster my $adjuster = $tree_adj_tablist->Adjuster( -widget => $tree, -side => 'left' ); $adjuster->pack( -side => 'left', -fill => 'y' ); # A scrolled tab_list widget my $tab_list = $tree_adj_tablist->Scrolled( 'TList', -background => 'White', -orient => 'vertical', -selectmode => 'extended', -scrollbars => 'os' ); $tab_list->pack( -expand => 'yes', -fill => 'both', -padx => 2, -pady => 2, -side => 'right' ); # Ok button my $ok = $main->Button( -text => 'Ok', -underline => 0, -width => 4, -command => sub { my $selected = $tab_list->info('selection'); #print "@{$selected}\n"; foreach( @{$selected} ){ print $tab_list->entrycget($_, '-text'),"\n"; } })->pack( -side => 'right', -padx => 10, -pady => 10 ); # A Quit button (will be suppressed???...) my $quit = $main->Button( -text => 'Quit', -underline => 0, -width => 6, -command => sub { exit } ); $quit->pack( -side => 'right', -padx => 10, -pady => 10 ); # Configuring tree and tab_list widgets... $tree->configure( -browsecmd => sub { list_dir( $tab_list, @_ ); } ); # We list the content of the initial dir inside the tab_list list_dir( $tab_list, $initial_dir ); MainLoop(); #--------------------------------------------------------------------- +------- # Displays Dirs and files in TList widget sub list_dir { my ( $tab_list, $path ) = @_; # Erase the TList content $tab_list->delete( 0, 'end' ); opendir MY_DIR, $path or return; foreach my $file ( sort readdir(MY_DIR) ) { # Do not display '.' and '..' next if ( $file eq '.' or $file eq '..' ); # Insert the files in the TList $tab_list->insert( 'end', -text => $file ); } closedir MY_DIR; }

        I'm not really a human, but I play one on earth. Cogito ergo sum a bum