moonkey has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to write a GUI for playing Goe, which is a board game polular in east Asia. As I want the program be able to run on all OS platforms(at least on Linux and Windows) without modification, Perl/Tk seems to be the right candidate.
I encoutered a problem with getOpenFile( ), and I included reduced sample code at the end of this message.
getOpenFile() works fine for the 1st window, but if I clone a window, getOpenFile() will generate the following error:
Tk::Error: image "image1" doesn't exist at /usr/lib/perl5/site_perl/i386-linux/Tk/FBox.pm line 91.
(the above is the 1st line of the errors) which I tried to eliminate but didn't succeed.
I am running the code on Slackware Linux 7.1, Perl 5.6.0, Tk800.024.
Please try the following code and I am desperately in need of all you monks' wisdoms.
(If my English is not accurate, please forgive your eastern counterpart :-)
#!/usr/bin/perl -w use strict; use Tk; my $FileName; NewWindow( ); MainLoop; sub NewWindow { my $mw = MainWindow->new; $FileName = ""; $mw->Button( -text => "New Window", -width => 16, -command => \&NewWindow )-> grid( -row => 0, -column => 0 ); $mw->Button( -text => "Select File", -width => 16, -command => [ \&ChooseAFile, $mw ] )-> grid( -row => 0, -column => 1 ); $mw->Button( -text => "Exit", -width => 16, -command => sub { $mw->destroy; } )-> grid( -row => 0, -column => 2 ); $mw->Label( -textvariable => \$FileName, -width => 50, -relief => "flat" )-> grid( -row => 1, -column => 0, -columnspan => 3 ); } sub ChooseAFile { my $mw = shift; my @types = ( [ "All files ", '*' ] ); $FileName = $mw->getOpenFile( -filetypes => \@types ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by svad (Pilgrim) on Apr 26, 2002 at 16:21 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by BlueBlazerRegular (Friar) on Apr 26, 2002 at 16:13 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by moonkey (Initiate) on Apr 27, 2002 at 07:55 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by svad (Pilgrim) on Apr 27, 2002 at 09:25 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by aplonis (Pilgrim) on Jan 15, 2005 at 00:01 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by vkonovalov (Monk) on Apr 26, 2002 at 16:30 UTC | |
|
Re: Perl/Tk getOpenFile( ) error in the other toplevel window
by vkonovalov (Monk) on Apr 26, 2002 at 16:30 UTC |