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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |