[Perl Tk] Module Tk::MesgBox (et non messageBox)
Bonsoir.
J'ai eu la curiosité de télécharger le module Tk::MesgBox, qui fournit une alternative au messageBox.
Dans mon programme, deux lignes du genre
Code:
1 2 3
|
my $msg = $monWidgetTexte->MesgBox( -text => "Bonjour");
$msg->Show; |
ont provoqué l'objection :
"Tk::Error: can't make ".toplevel.frame1.textundo.mesgbox" its own master at C:/Perl/site/lib/Tk/Submethods.pm line 37.
at C:/Perl/site/lib/Tk/MesgBox.pm line 62
Tk callback for wm
(menu invoke)"
Si je comprends bien, c'est le module Tk::MesgBox qui est en cause. Je reproduis la routine où figure la ligne 62 de ce module :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
sub Populate {
my ($win, $args) = @_;
my %arg = (
-title => 'Message',
-text => 'Press OK to continue...',
-textfg => 'black',
-textbg => 'lightgrey',
-icon => undef,
-defbutton => 'OK',
-canbutton => '', # Usually 'Cancel'.
-buttons => ['OK'],
-buttonpadx => 0,
-buttonpady => 0,
-buttonfg => 'black',
-buttonbg => 'lightgrey',
-buttonHL => 'lightgrey',
-buttonfont => '-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*',
-aspect => 500,
-justify => 'center',
-bindctrl => 1,
-bindalt => 1,
-bindord => 1,
%$args,
);
# We don't delete the title.
delete @{$args}{qw(
-text -textfg -textbg -icon -defbutton -canbutton
-buttons -aspect -justify -bindctrl -bindalt
-bindord -buttonpadx -buttonpady -buttonfg
-buttonbg -buttonfont -buttonHL -buttonfont
)};
$win->SUPER::Populate($args);
$win->withdraw;
$win->iconname($arg{-title});
$win->protocol('WM_DELETE_WINDOW' => sub { });
$win->transient($win->toplevel); #### Problème.
$win->{-default_button} = &create_buttons($win, %arg);
&create_text_frame($win, %arg);
$win->{-selected_button} = '';
} |
La ligne 62 du module est la ligne
Code:
1 2
|
$win->transient($win->toplevel); |
On dirait donc qu'il y a un bug dans ce module (bizarre tout de même, car il rend le module inutilisable, donc on aurait dû s'en rendre compte).
Peut-être faudrait-il
Code:
1 2
|
$win->transient($win->parent()); |
?
Merci d'avance pour tout avis.
M.