Dear monks,
I have a problem with perl Tk application. I'm using a getOpenFile widget wich works fine. But there is an issue if I select the file using a double-click. The file picker dialog opens in front of the main window, then I select a file by double click, the file picker dialog closes and returns a selected file, but now comes the problem: main window recieves one additional click. Sometimes this click hits a button so an action may start unintentionally. Is somebody there who experienced this problem already? Thank you. I'm using Windows 7 64-bit with StrawberryPerl 5.12...
here is a code which reproduce a problem easily (cause of the huge button) it's easy to place the file picker window over this button and select a file using a double click. A message box opens after the huge button has been clicked to inform you.
#!/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 {
#...;
my $file = $mw->getOpenFile(
-title => 'select file',
);
$file = File::Spec->canonpath( $file );
return $file;
}
sub buttonClicked {
$mw->messageBox(-message=>"you clicked a button!");
}
Update: it seems to be allready known problem
http://groups.google.com/group/comp.lang.perl.tk/browse_thread/thread/d18d09ac8cd1fff6/4262df12756a36bf?#4262df12756a36bf. Wonder if there is still no bug report about it.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.