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; }

In reply to Tk strangeness by RonW

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.