If you have code that actually runs, you should paste the relevant part of the running code when you post (or at least be more careful about typing/pasting it in). What you have here has some glaring errors. Update as you see fit (and mention what you've updated), but when I first saw this post, there were the following problems:

As for the symptom -- the buttons appear to be labeled as intended, but you aren't seeing the file name or its contents in the new Toplevel window when you hit a button -- well, it's hard to comment on this, because you say your code runs, but what you've posted won't run, so you haven't posted the code that produces that symptom.

Anyway, you might try initializing the "-command" parameter on the button like this:

... -command => [ \&view, $open ], ...
This way, the "-command" option gets a reference to an anonymous array; the first element of the array is a reference to a subroutine to be run when the button is clicked, and subsequent elements in the array (one in this case) are parameters to be passed to the subroutine in @_.

In reply to Re: creating tk buttons with for loop by graff
in thread creating tk buttons with for loop by K_M_McMahon

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.