Click here to get back home

Perl Tk::FBox and filter argument

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Perl Tk::FBox and filter argument Andy 01-30-2007
Get Chitika Premium
Posted by Andy on January 30, 2007, 2:40 pm
Please log in for more thread options


Does anyone know what the file pattern format is for the -filter
argument of the perl tk::fbox module? The CPAN documentation for the
module says filter is to be documented at a later date.

The following code doesn't crash, however, the fileselector that is
displayed isn't showing any .xls files even though I know they are in
the directory. And, the "Files of Type" droplist in the fileselector
is greyed out and disabled even though the filter specifies two
choices. If I remove the -filter argument, the fileselector shows all
files in the directory:

use Tk;
use Tk::FBox;

my $mw = MainWindow->new;
$spreadsheetfilename = $mw->FBox(
-type => "open",
-filter =>[
['Excel Files',['*.xls']],
['All Files','*.*']
]
)->Show;

I'm running Perl on windows XP.

Andy


Posted by Andy on January 30, 2007, 3:01 pm
Please log in for more thread options


Sorry folks,

oops! brackets are out of balance: the code really is (but it still
doesn't work):

$spreadsheetfilename = $mw->FBox(-type => "open",
-filter =>[
['Excel Files',['*.xls']],
['All Files',['*.*']]
]
)->Show;


Posted by Ch Lamprecht on January 30, 2007, 3:37 pm
Please log in for more thread options


Andy wrote:
> Does anyone know what the file pattern format is for the -filter
> argument of the perl tk::fbox module? The CPAN documentation for the
> module says filter is to be documented at a later date.
>
> The following code doesn't crash, however, the fileselector that is
> displayed isn't showing any .xls files even though I know they are in
> the directory. And, the "Files of Type" droplist in the fileselector
> is greyed out and disabled even though the filter specifies two
> choices. If I remove the -filter argument, the fileselector shows all
> files in the directory:
>
> use Tk;
> use Tk::FBox;
>
> my $mw = MainWindow->new;
> $spreadsheetfilename = $mw->FBox(
> -type => "open",
> -filter =>[
> ['Excel Files',['*.xls']],
> ['All Files','*.*']
> ]
> )->Show;
>
> I'm running Perl on windows XP.
>
> Andy
>
Maybe you want to use the -filetypes option??
-filter takes a glob expression. - or a coderef?
It is used internally, so you can't mix these.

my $spreadsheetfilename = $mw->FBox(
-type => "open",
#-filetypes =>[
#['Excel Files',['*.xls']],
#['All Files','*.*']
#],
-filter => '*.x++'
)->Show;

But why don't you use $mw->getOpenFile()?

Christoph

--
use Tk;package Tk::_;@ISA=('Tk::Frame');Tk::Widget->Construct
qw|_|,@?=qw'Just another Perl Hacker';sub Populate{($j)=@_;
$j->SUPER::Populate;$j->configure(-label=>shift@?)}
main::tkinit->_->$_->_->$_->_->$_->_->$_->update for 'pack';sleep 5;

Posted by Andy on January 30, 2007, 4:17 pm
Please log in for more thread options


you are right! getOpenFile pops up the native windows file selector.
Don't know why I didn't use it before... I tried several different
Perl fileselectors and the fbox one looked closest to windows - I
never got the native windows selector in my experimentation before.

For those using fbox, the -filter function accepts a Perl glob()
function which holds a file mask:

$spreadsheetfilename = $mw->FBox(-type => "open",
-filter =>glob('*.xls'),
)->Show;

I found the missing documentation for fbox's -filter argument:

-filter => $val
A filter to restrict the directories and files in the icon
list. If
specified as a glob pattern, then only files will be
filtered by
the pattern. If specified as a subroutine, then this
subroutine
will be called for every file and directory and should
return a
true value, if the argument should be accepted for the icon
list.
The arguments of this subroutine are: FBox widget
reference, base-
name of file, and directory name.

The subroutine form of this option is experimental.


thanks for the help,
Andy


Similar ThreadsPosted
Win32::Process::Create(vxsim) cmd line argument trouble December 17, 2007, 9:05 am
Filter::Simple bug? December 21, 2004, 9:54 pm
opendocument -> csv filter ? September 20, 2006, 10:28 am
Email::Filter hello world August 15, 2004, 3:36 pm
where can download Filter::netcrypt February 22, 2005, 9:55 pm
Printing xlated output of Filter::Simple ? November 13, 2004, 6:15 pm
can apache::filter work with virtual location? July 28, 2007, 10:36 pm
ANNOUNCE: Initial release of WSF/Perl (Perl bindings for a WS-* framework) October 4, 2007, 1:37 am
PLJava - Perl embeded into Java (calling Perl from Java) - 1sr release - call for tests and review, please. July 13, 2004, 4:06 am
Perl MakeMaker - how to force Perl linking with the static C library (libcrt.lib) instead of dynamic C library (msvcrt.lib) April 17, 2007, 5:22 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap