[Israel.pm] Perl/Tk - getOpenFile() de-activates my buttons
Erez Schatz
moonbuzz at gmail.com
Sun May 4 13:50:36 EEST 2008
Works for me, in the sense that after choosing a file, both buttons -
> $mw->Button( -text=>'Quit', -command=>sub{ exit } )->pack( -side=>'right' );
> $mw->Button( -text=>'Quit', -command=>sub{ exit } )->pack;
are clickable and both quit the application.
It also shows the file name and the filename+"_949.sav";
Try giving a specific test case that will be of assistance here,
otherwise I can't replicate it.
On Sun, May 4, 2008 at 1:08 PM, Oren Maurer <meorero at gmail.com> wrote:
> Hi all.
>
> I'm trying to write a small GUI using Perl/Tk.
> It should select a file, and than - display it's name and by pressing
> a button – do something.
>
>
> After using my $inputfilename = $mw->getOpenFile(-filetypes =>
> $types); all the buttons are un-clickable!
>
> Here is my code:
> ==============================================================================
>
> #!/usr/bin/perl -w
> use strict;
> use Tk;
> use Tk::DirTree;
> use Cwd;
>
>
> my $mw = MainWindow->new ();
> $mw->Label( -text => "Adding 949 field!" );
>
> my $types = [
> ['MARC\XML Files', ['.xml', '.mrc','mrcxml', 'xmlmrc']],
> ['All Files', '*', ],
> ];
>
> my $inputfilename = $mw->getOpenFile(-filetypes => $types);
> &see_inputfilename($inputfilename) if defined $inputfilename ;
> #---
> sub see_inputfilename {
> $mw->Label( -text => "$inputfilename" )->pack;
> }
>
> my $outputfilename = "$inputfilename"."_949.sav";
> &see_outputfilename($outputfilename) if defined $outputfilename;
> #---
> sub see_outputfilename {
> $mw->Label( -text => "$outputfilename" )->pack;
> }
>
> $mw->Button( -text=>'Quit', -command=>sub{ exit } )->pack( -side=>'right' );
> $mw->Button( -text=>'Quit', -command=>sub{ exit } )->pack;
>
> sub add_949_field {
> my ($inputfilename, $outputfilename) = @_;
> my $inputfilename_val = $inputfilename->get;
> my $outputfilename_val = $outputfilename->get;
> return "Taking inputfilename $inputfilename_val to add 949 field
> into outputfilename $outputfilename_val\n";
> }
>
> MainLoop;
>
>
> ==============================================================================
>
>
> --
> ________________________________
> Oren Maurer
> http://www.meorero.org.il
> _______________________________
> # =======================|
> # Please avoid sending me Word |
> # or PowerPoint attachments |
> # =======================|
> # See: http://www.gnu.org/philosophy/no-word-attachments.html
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>
--
Erez
It's time to grow out of the browser; we have nothing to lose but our metaphors.
More information about the Perl
mailing list