Hi,
I have a question about a particular behavior of Wx::FileDialog on
Windows. The script below is not a particularly special use of
Wx::FileDialog, but it is typical of how I use it. It should
demonstrate my question.
Suppose that you want to follow a Windows shortcut file that points to
a folder. Opening that shortcut file with "All files" selected as the
wildcard will return the .lnk file as a file rather than following it
into its target folder.
If, however, you change the wildcard to the other option (*.dat in my
example) and open or double click on the shortcut, the FileDialog will
follow the shortcut into the target folder.
I find this to be surprising behavior. Is there some way of
specifying either the wildcard or the style such that the dialog will
always follow a Windows shortcut into a folder?
Or is the solution that I need not to be surprised by that behavior!
Thanks!
Bruce
========= snip =====================================================
#!/usr/bin/perl
package MyApp;
use base 'Wx::App';
use Wx qw(:everything);
use Wx::Event qw(EVT_BUTTON);
use Cwd;
$|=1;
sub OnInit {
my $frame = Wx::Frame -> new(undef, -1, 'demo');
my $box = Wx::BoxSizer->new(wxVERTICAL);
my $button = Wx::Button->new($frame, -1, "Open file");
$box -> Add($button, 0, wxALL, 5);
EVT_BUTTON($frame, $button, \&doOpen);
$frame -> SetSizerAndFit($box);
$frame -> Show(1);
1;
};
sub doOpen {
my ($frame, $event) = @_;
my $fd = Wx::FileDialog->new( $app->{main}, "Open file", cwd, q{},
"All files|*|Data (*.dat)|*.dat",
wxFD_OPEN|wxFD_FILE_MUST_EXIST|wxFD_CHANGE_DIR,
wxDefaultPosition);
if ($fd->ShowModal == wxID_CANCEL) {
print "Data import cancelled\n";
return;
};
print $fd->GetPath, $/;
};
package main;
use Wx qw(:everything);
my $app = MyApp->new->MainLoop;
--
Bruce Ravel ------------------------------------ [email protected]
National Institute of Standards and Technology
Synchrotron Methods Group at NSLS --- Beamlines U7A, X24A, X23A2
Building 535A
Upton NY, 11973
Homepage: http://xafs.org/BruceRavel
Software: https://github.com/bruceravel