Hello Dear Monks,
I'm trying to create my first GUI and don't understand the following :
use strict;
use warnings;
use Tk;
use Tk::DialogBox;
my $main_window = MainWindow -> new();
$main_window -> bind ( "<Control-Key-c>" , \&add_client ) ; # Ctrl c
MainLoop;
sub add_client {
my $add_client_win = $main_window -> DialogBox (
-title => 'Ajouter un client' ,
-buttons => [ 'Valider' , 'Annuler' ]
);
# BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE
#my $firstname_line = $add_client_win -> add ( 'Label' ,
# -height => '30'
#) -> pack(
# -side => 'top' ,
# -fill => 'x'
#);
# END BUG END BUG END BUG END BUG END BUG END BUG END BUG END BUG
# -- CANTON --
my $canton_line = $add_client_win -> add ( 'Label' ,
-height => '30'
) -> pack(
-side => 'top' ,
-fill => 'x'
);
my $label_canton = $canton_line -> Label (
-font => 'Helvetica 10 bold' ,
-text => 'Localisation :',
-padx => '10' ,
-pady => '5'
) -> pack (
-side => 'left'
);
my ($canton_data, $canton_display );
my $canton_choice = $canton_line -> Optionmenu(
-options => [
[ 'Genève' => '000' ] ,
[ 'Vaud' => '100' ] ,
[ ' - Chablais vaudois' => '110' ] ,
[ ' - Lausanne' => '120' ] ,
[ ' - Montreux-Vevey' => '130' ] ,
[ ' - Morges' => '140' ] ,
[ ' - Nyon' => '150' ] ,
[ ' - Yverdon' => '160' ] ,
[ ' - Arc lémanique' => '170' ] ,
[ 'Valais' => '200' ] ,
[ ' - Chablais valaisan' => '210' ] ,
[ ' - Bas Valais' => '220' ] ,
[ ' - Haut Valais' => '230' ] ,
[ 'Fribourg' => '400' ] ,
[ 'France voisine' => '500' ] ,
[ 'Paris' => '600' ] ,
[ 'Cote d Azur' => '700' ] ,
[ 'Italie' => '800' ] ,
] ,
-command => sub { } ,
-variable => \$canton_data ,
-textvariable => \$canton_display
) -> pack(
-side => 'right' ,
);
my $reponse = $add_client_win -> Show ( ) ;
}
This code works, but when I uncomment the lines between BUG HERE and END BUG, the -text option in my $label_canton disappears.
If I minimize the window or hide it with another window from another app and restore it the text is here again.
And I don't understand WHY
Thanks.
Have a nice day<>/p
P.S Ctrl-c to see the dialogbox
complete code here
"There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.