For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2005 > Tk::FileSelect hangs on W98 root directory









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Tk::FileSelect hangs on W98 root directory
Richard Trahan

2005-06-07, 8:57 am

I'm running ActiveState build 811 on W98. When using Tk::FileSelect,
attempting to navigate to the root directory of any drive hangs the
interpeter. There is no mention of this problem in this ng. Is anyone
else experiencing this?
A. Sinan Unur

2005-06-07, 8:57 pm

Richard Trahan <rtrahan@optonline.net> wrote in news:DCepe.55175$NZ1.51778
@fe09.lga:

> I'm running ActiveState build 811 on W98. When using Tk::FileSelect,
> attempting to navigate to the root directory of any drive hangs the
> interpeter. There is no mention of this problem in this ng. Is anyone
> else experiencing this?


How about a short, complete script that still exhibits the problem so that
others can try it out?

Please read the posting guidelines for this group. They contain valuable
information on how to help yourself as well as on how to help others help
you.

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/c...guidelines.html
Richard Trahan

2005-06-07, 8:57 pm

A. Sinan Unur wrote:
> How about a short, complete script that still exhibits the problem so that
> others can try it out?
>

use strict;
use Tk;
use Tk::FileSelect;

our $mw = MainWindow->new;
$mw->Button(
-command => \&fs
)->pack;

MainLoop;

sub fs
{
$mw->FileSelect(-directory => "c:/windows/temp")->Show;
}

The above program will allow me to click up to /windows, but if I go
higher, the program hangs.
W. Citoan

2005-06-08, 3:59 am

Richard Trahan wrote:
> I'm running ActiveState build 811 on W98. When using Tk::FileSelect,
> attempting to navigate to the root directory of any drive hangs the
> interpeter. There is no mention of this problem in this ng. Is anyone
> else experiencing this?


Your example code works fine for me (811 on XP). A quick Google search
shows that this appears to be a known problem on 98.
http://groups-beta.google.com/group...98%20FileSelect
Look at the 1st and 2nd thread. The first thread suggests using
getOpenFile instead (which uses the standard Windows interface).

- W. Citoan
--
If voting changed anything, they'd make it illegal.
-- Graffiti
Richard Trahan

2005-06-08, 8:58 am

W. Citoan wrote:
> Richard Trahan wrote:
>
>
>
> Your example code works fine for me (811 on XP). A quick Google search
> shows that this appears to be a known problem on 98.
> http://groups-beta.google.com/group...98%20FileSelect
> Look at the 1st and 2nd thread. The first thread suggests using
> getOpenFile instead (which uses the standard Windows interface).
>
> - W. Citoan


Thank you for your response. I will use that method, but there is still
something wrong with it.

The example shown in the Perl html page for getOpenFile shows a
variable, $types, as a list of lists, and it works ok as shown, but if
you reduce this list to a single line, you get a syntax error. Specifically:
my $types = [
['Text Files', ['.txt','.text']],
];
will not work. IMO, this is clearly a bug. Notice also that the syntax
of $types is inconsistent with the description under the heading
"Specifying File Patterns"; the $types example shows an extra level of
list nesting.

It's too bad they didn't fix FileSelect; getOpenFile is not quite the
same because it isn't a widget and it allows the user to do things I
don't want him/her to do, like delete files and create directories.

In the context of the birth and death of galaxies, I suppose it's not
that important.
Richard Trahan

2005-06-08, 8:58 am

Also, it ignores -initialdir.
W. Citoan

2005-06-09, 3:57 am

Richard Trahan wrote:
>
> The example shown in the Perl html page


Eh, there are tons of webpages out there. I am assuming you mean the
ActivePerl page? That's a copy of the manpage.

> for getOpenFile shows a variable, $types, as a list of lists, and it
> works ok as shown, but if you reduce this list to a single line, you
> get a syntax error. Specifically:
> my $types = [
> ['Text Files', ['.txt','.text']],
> ];
> will not work. IMO, this is clearly a bug.


Not quite. I believe that when you reduce it to a single line, you no
longer have a list of lists, but instead you merely have a list. I'm
not the best at those subtleties however so I may have it wrong. I do
know that to have a single pattern you would use:

my $types = [
['Text Files', ['.txt', '.text']],
[],
];

> Notice also that the syntax of $types is inconsistent with the
> description under the heading "Specifying File Patterns"; the $types
> example shows an extra level of list nesting.


Again, not quite. It's not the clearest, but under the DESCRIPTION
section, filetypes is specified (via the [] usage) as taking a list.
Under the SPECIFYING FILE PATTERNS section, it says (the first line)
that filePattern is a list. That results in a list of lists and the
example is consistent.

> It's too bad they didn't fix FileSelect; getOpenFile is not quite the
> same because it isn't a widget and it allows the user to do things I
> don't want him/her to do, like delete files and create directories.


getOpenFile simply calls a native interface. On Windows, you get the
standard Windows open file dialog. The advantages of providing the
users a dialog they are already quite familiar with out weigh such
considerations in my mind. Especially since they can always open an
Explorer window and delete those files anyway.

But you could try at Tk::FBox as well. Look toward the end of this
page: http://www.perltk.org/articles/file...iledialogs.html

- W. Citoan
--
Practice is the best teacher.
-- Publiluis Syrus
W. Citoan

2005-06-09, 3:57 am

Richard Trahan wrote:
> Also, it ignores -initialdir.


No, it doesn't. However, on Windows, it will only recognize the
backslash and not the customary (well, at least for Perl) slash.

$top->getOpenFile(-filetypes => $types,
-initialdir => 'C:\Perl');

By the way, the answer to that can be found very easily by searching
google groups for:

perl getopenfile initialdir

You would have found plenty of answers to that problem and have had your
solution much quicker.

- W. Citoan
--
Practice is the best teacher.
-- Publiluis Syrus
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com