Greetings All,
I am trying to bind the mouse click actions to 2 separate sub-routines, eg: one click will bind to sub_one and double click will bind to sub_two, below is the script (I am new to Tk and was helped by monk .dave. to produce this script), please brethrens enlighten me.
And the Other thing is, the $output_text window appears to me that it will only display text, is it possible to include iconic display as well as text?
use Tk; use strict; use Tk::Text; use Tk::Frame; use Tk::DirTree; use Tk::Adjuster; use Tk::Scrollbar; my $mw = new MainWindow; $mw->geometry('500x600'); my $left_frame = $mw->Frame; my $right_frame = $mw->Frame; my $dir_label = $mw->Label(-text => 'Path :'); my $dir_name = $mw->Entry(-width => 30, -textvariable => \ my $variabl +e); my $adjuster = $mw->Adjuster(-widget=>$left_frame, -side=>'left'); my $list_box = $left_frame->Scrolled('DirTree', -height=>'0', -width=> +'0', -scrollbars =>'e',); my $output_text = $right_frame->Scrolled('Text', -height=>'1', -width= +>'1', -scrollbars=>'osoe',); $top_frame->pack(qw/-side top/); ####Errors occure in this '#' enclosed section####################### $list_box->bind('<ButtonRelease-1>', sub {my $indx = $list_box->cursel +ection(); my $selected_object = $list_box->get($indx);}); $list_box->bind('<ButtonRelease-2>', sub{print “\nuser clicked twice”; +}); ##################################################################### $dir_label->pack (qw/-side top -anchor w/); $dir_name->pack (qw/-side top -anchor e/); $left_frame->pack(qw/-side left -fill y/); $adjuster->pack(qw/-side left -fill y/); $right_frame->pack(qw/-side right -fill both -expand 1/); $list_box->pack(qw/-side left -fill both -expand 1/); $output_text->pack(qw/-side bottom -fill both -expand 1/); MainLoop; exit();
Many thanks in advance….

In reply to Binding mouse clicks in perl/Tk by blackadder

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.