RonW has asked for the wisdom of the Perl Monks concerning the following question:
A coworker tried to run a Perl/Tk program I worte under Win7 with Strawberry Perl 5.16.3
He got the error:
C:\Users\rowilson\Projects\Tools>perl UpdateP4SM.pl Tk::Error: bad file type "ARRAY(0x7ad618)", should be "typeName {exten +sion ?exte nsions ...?} ?{macType ?macTypes ...?}?" at c:/Perl/perl/site/lib/Tk.p +m line 338
The filetype specification is almost copy/paste from Tk:getOpenFile and it worked on my Linux system.
Also, I changed the program to use Tk::FBox, instead, but while it works, when the program starts, a partially functioning (and useless) FBox is opened. Ok and Cancel have no affect. But, when the button on the main window is clicked, the useless one disappears and a properly functioning one appears.
My code (with the business logic removed) is:
#!perl -w use strict; use Tk; use Tk::Label; use Tk::Text; use Tk::Button; use Tk::FBox; my $Type_P4SM = [ [ 'P4SM', '.p4sm' ] ]; my $File_P4SM; my $mw=MainWindow->new(-title=>'UpdateP4SM'); my $w_Lab_Step1 = $mw -> Label ( -justify=>'left', -relief=>'flat', -t +ext=>'Copy/Paste Commit Log from P4 to here:' ) -> grid(-row=>0, -col +umnspan=>3, -column=>0, -sticky=>'nw'); my $w_Text_Commit = $mw -> Scrolled ( 'Text', -state=>'normal', -relie +f=>'sunken', -scrollbars=>'se', -wrap=>'none' ) -> grid(-row=>1, -col +umnspan=>3, -column=>0, -sticky=>'nw'); my $w_Lab_Step2 = $mw -> Label ( -justify=>'left', -relief=>'flat', -t +ext=>'P4SM file to update:' ) -> grid(-row=>2, -column=>0, -sticky=>' +nw'); my $w_Button_P4SM = $mw -> Button ( -overrelief=>'raised', -command=>\ +&Show_Open_P4SM, -width=>20, -state=>'normal', -relief=>'raised', -co +mpound=>'none', -textvariable=>\$File_P4SM ) -> grid(-row=>2, -column +=>1, -sticky=>'nwe'); my $w_FBox_P4SM = $w_Button_P4SM -> FBox ( -title=>'Select P4SM to Upd +ate', -filetypes=>$Type_P4SM, -type=>'open' ); my $w_Button_Update = $mw -> Button ( -overrelief=>'raised', -command= +>\&updateP4SM, -state=>'normal', -relief=>'raised', -text=>'Update', +-compound=>'none' ) -> grid(-row=>3, -column=>1, -sticky=>'new'); my $w_Button_Quit = $mw -> Button ( -overrelief=>'raised', -command=>\ +&Quit, -state=>'normal', -relief=>'raised', -text=>'Quit', -compound= +>'none' ) -> grid(-row=>4, -column=>2, -sticky=>'ne'); MainLoop; sub Show_Open_P4SM { # $File_P4SM = $mw->getOpenFile( -title=>'Select P4SM to Update', +-filetypes=>$Type_P4SM ); $File_P4SM = $w_FBox_P4SM->Show(); } sub updateP4SM { print "Updating $File_P4SM....\n"; } sub Quit { Tk::exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk strangeness
by kevbot (Vicar) on May 10, 2014 at 04:06 UTC | |
by Anonymous Monk on May 10, 2014 at 06:56 UTC | |
by RonW (Parson) on May 12, 2014 at 19:55 UTC | |
|
Re: Tk strangeness
by kevbot (Vicar) on May 13, 2014 at 03:51 UTC |