There are several ways it can be done... it depends on what your needs are. This is one possible way. Here is a modified openfile() sub that will print to the command window the index of the closest character and the text on that line to whichever checkbox is clicked.

Note there are a LOT of shortcomings with what you have here and this doesn't really address them... I just made minimal changes to give you an example. (and perltidied the code so I could read it easier.)

sub openFile { my $cb_value; my @types = ( [ "3d Files", '.3d' ], [ "Excel Files", '.xls' ], [ "All files", '*' ] ); $filename = $mw->getOpenFile( -filetypes => \@types, -initialdir => $filename, # -initialfile => $filename, -defaultextension => '.3d', -title => 'file to read' ); $mw->Unbusy; return 'Cancel' unless ($filename); $mw->update; $w = $ins->Text( -height => '1', -font => 'Arial 10', -wrap => 'word', -relief => "flat", -highlightbackground => 'white', -highlightthickness => '1', -highlightcolor => 'red' ); $w->insert( 'end', "$filename" ); $ins->windowCreate( 'end', -window => $w ); my $ww = $ins->Checkbutton( -variable => \$cb_value, -command => [ sub { print "$cb_value | "; print 'Index = ', $_[0]->index( '@' . $_[0]->pointerx . ',' . $_[0]->p +ointery ), " | ", $_[0]->get( $_[0] ->index( '@' . $_[0]->pointerx . ',' . $_[0]->po +intery ) . ' linestart', $_[0] ->index( '@' . $_[0]->pointerx . ',' . $_[0]->po +intery ) . ' lineend' ), "\n"; }, $w ] ); $ins->windowCreate( 'end', -window => $ww ); }

In reply to Re: TK Help by thundergnat
in thread TK Help by srikrishnan

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.