marbu has asked for the wisdom of the Perl Monks concerning the following question:

Hi there. I got a fresh installation of Strawberry Perl (v 5.32.1.1) and installed Tk (804.036) and Tk::ExecuteCommand.

When I start this simple test script, I got an error I can't fix. Btw - I'm totally new on perl programming.

use Tk; use Tk::ExecuteCommand; $ec = tkinit()->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'C:\\WINdows\\system32\\NOTEPAD.EXE'); $ec->execute_command; $ec->update;
The Error:

bad option "pady": must be -after, -anchor, -before, -expand, -fill, -in, -ipadx, -ipady, -padx, -pady, or -side at C:/Strawberry/perl/site/lib/Tk/Widget.pm line 1217. at C:/Strawberry/perl/site/lib/Tk/Widget.pm line 203

Thanks for your help. Markus

Replies are listed 'Best First'.
Re: Problems using Tk::ExecuteCommand
by kcott (Archbishop) on Jul 08, 2021 at 20:52 UTC

    G'day marbu,

    Welcome to the Monastery.

    The code you posted was not the code that generated that error message. Please don't do that.

    Most (if not all) of Tk's option/value pairs have a '-' before the option (e.g. -option => $value).

    Your problem, in your real code, stems from writing pady, instead of -pady, in pack() (see Tk::pack).

    Here's a working example:

    $ perl -e 'use Tk; MainWindow->new()->Button(-text => "?")->pack(-pady + => 2); MainLoop'

    Here's your error replicated:

    $ perl -e 'use Tk; MainWindow->new()->Button(-text => "?")->pack(pady +=> 2); MainLoop' bad option "pady": must be -after, -anchor, -before, -expand, -fill, - +in, -ipadx, -ipady, -padx, -pady, or -side at /long/path/to/Tk/Widget +.pm line 1217. at -e line 1.

    Here's another example (with '-' omitted from the -text option in Button()):

    $ perl -e 'use Tk; MainWindow->new()->Button(text => "?")->pack(-pady +=> 2); MainLoop' unknown option "text" at /long/path/to/Tk/Widget.pm line 205. at -e line 1.

    See also Tk::options.

    By the way, you can completely ignore the first answer you got which talked about "unixisms" and suggested threads would fix the problem. This looks like trollage to me: I downvoted it.

    Update: Linkified the "the first answer you got" text. It now points to the actual node referenced.

    — Ken

      By the way, you can completely ignore the first answer you got which talked about "unixisms" and suggested threads would fix the problem. This looks like trollage to me: I downvoted it.

      But your code doesn't attempt to use Tk::ExecuteCommand on windows :/

        "... your code doesn't attempt to use Tk::ExecuteCommand ..."

        Of course not, that isn't the source of the reported error.

        — Ken

Re: Problems using Tk::ExecuteCommand on windows (win32 win64)
by Anonymous Monk on Jul 08, 2021 at 09:19 UTC

      I was wondering what "unixisms" you refered to and found in Tk::ExecuteCommand's source code this: open $h, $self->{-command} . ' 2>&1 |'; . Does anyone know if that's valid in win?

        Do you have windows? Get windows and try stuff

        for me, the OPs program doesn't trigger the -tk -option -error -reported

        Tk::ExecuteCommand however does not work

        Can't stat /dev: No such file or directory at ... Proc/ProcessTable.pm

        Tk fileevent doesn't work on windows

      Good morning and many thanks for the quick reply. Will try to test it the next days. Just like I said I'm totally new on perl programming and try to find a way through all the scripts here ath work. Thanks and have a great weekend. Markus
        Thanks again for all your help.

        Couldn't find a way through this problem. We now just use an older version of TK and it works. Just used in a small amount of scripts so we can ignore.

        Have a great day.

        Greetings Markus