There is a workaround on described on http://www.rhinocerus.net/forum/lang-perl-tk/187668-checkbutton-problem.html which I also implemented in the following code. This workaround disables a click functionality for a button before calling getOpenFile and restores it after little delay. Is there a wise monk who knows more elegant solution?
#!/usr/local/bin/perl -w use strict; use warnings; use Tk; use utf8; use v5.12; my $mw = Tk::MainWindow->new( -title => 'main window', ); #Exit when the escape key is pressed $mw -> bind('<Key-Escape>', sub { exit }); my $frame = $mw->Frame(-borderwidth => 3)->pack( -fill => 'both',); my $btn1 = $frame->Button( -text => 'button', -command => sub { buttonClicked() }, -width => 120, -height => 40, )->pack(-fill => 'both',); $frame->Button( -text => 'file selector', -command => sub { select_file() }, )->pack(-fill => 'both',); $frame->Button( -text => 'exit', -command => sub { exit }, )->pack(-fill => 'both',); MainLoop; sub select_file { breakCheckbuttonBindings(); my $file = $mw->getOpenFile( -title => 'select file', ); $file = File::Spec->canonpath( $file ); $mw->after(25,\&restoreCheckbuttonBindings); return $file; } sub buttonClicked { $mw->messageBox(-message=>"you clicked a button!"); } sub breakCheckbuttonBindings { my @tags = $btn1->bindtags; $btn1->bindtags([@tags[1,0,2,3]]); $btn1->bind('<ButtonPress>'=>sub{Tk->break}); } sub restoreCheckbuttonBindings { my @tags = $btn1->bindtags; $btn1->bindtags([@tags[1,0,2,3]]); $btn1->bind('<ButtonPress>'=>''); }

In reply to Re: Tk getOpenFile doubleClick problem by wwe
in thread [Solved:]Tk getOpenFile doubleClick problem by wwe

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.